title: .NET Application Memory usage grow over time, memory leak or not?
body: <p>I wrote a .NET application where memory usage is growing over time. As a test,
  I set it up to download 800 * 5K (average) size files and doing XML transform and using DTComcontroller to generate manifest, inside 1 hour with an interval of 15 Minutes. During a period of about 5 hours, memory usage grows from 35M to about 70M.</p>
  
  <p>Not sure if this is normal or not. I'm already forcing it by doing</p>
  
  <pre><code>GC.collection();
  GC.WaitForPendingFinalizers();
  </code></pre>
  
  <p>at end of each working circle just to make sure the memory are released in a timely manner.</p>
  
  <p>I already make sure close filehandle, clear stream or other resources after used it. And some objects are just using local references inside a function and I assume they will be discarded at the end of local function and go away with GC.collction().</p>
  
  <p>Also Memory Profiler (ANTS) shows that there are no objects with my application's namespace left at the end of each of the working circle, and no new objects with source code available left as well. The new instances of objects created during each working circle are basically called RuntimeModule, RuntimeAssembly, and DeviceContext. Doesn't looks like I could do anything about it?</p>
  
  <p>This is basically my first application which are suppose to run 24/7 and I really don't know much about memeory leak. More likely than not, there are still problems with memory usage in my application. I just don't know where to look at this stage.</p>
  
  <p>Also, I don't know it's related or not, I am using .net Trace/debug for keep a log. Guess it worth trying to turn off the log to see the memory usage grow.</p>
  
  <p>Update: 
  <img src="https://i.stack.imgur.com/4RV2L.png" alt="alt text">
  Dose it look like circle reference of sslstate and sslstream and also other Classes in the class Reference Explorer. Also not sure if that is a circle reference in ANTS generated graph, that means there is actually circle reference in my code somewhere?</p>
  
  <p>I did a few changes by reusing the same object for XMLtransform and Manifest creation, and manually set each Object to null after finish used them in the end of working iteration. Now the memory are greatly reduced, still increase private memory usage as it is working, but much slowly.</p>
  
  <p>I think for my particular case--create lots of objects inside a working circle, and every data is kept in a working thread. If I didn't explicitly release object references, let .NET GC doing that will lead to lots of memory used by the application as it is keep working most of the time, and GC may never get a chance to probably doing house keeping unless the application been manually closed, I have to do the object release much more manually.<br>
  @WeNeedAnswers:</p>
  
  <pre><code>            XmlDocument doc = new XmlDocument();
              XmlTextReader textReader = new XmlTextReader(dataFile);
              textReader.Read();
              doc.Load(textReader);
  </code></pre>