title: Limiting the use of RAM. (C# .NET)
body: <p>There are huge files about 100Mb.
  I want to load them into memory (RAM), process and save somewhere.</p>
  
  <p>At the same time I want that a limit of memory usage exists. Example, 100Mb, to my app don't use more then this memory limit. If the limit is exceeded the file is processed parts.</p>
  
  <p>My understanding of this:</p>
  
  <pre><code>var line = file.ReadLine();
  var allowed = true;
  
  while( allowed &amp;&amp; line != null ) 
  {
     var newObject = new SomeObject( line );
     list.add( newObject );
  
     // Checking the memory
     allowed = CheckUsedMemory(); 
  
     line = file.ReadLine()
  } 
  </code></pre>
  
  <p>How to limit the use of RAM?
  How to implement the CheckUsedMemory method? 
  Thank you.</p>
  
  <p><strong>UPD</strong></p>
  
  <p>Thank you everybody for good advices.</p>