title: How to totaly clear memory after remove object in C#
body: <p>How to clear memory after using object?</p>
  
  <p>A read a lot of question on this forum and every body say: Use <code>myObject=null</code> for delete your object.
  Like this:</p>
  
  <pre><code>Car myCar = new Car();
  
  //do stuff
  myCar.horn();
  
  myCar = null; // &lt;-- DELETE
  </code></pre>
  
  <p>In my program, I am creating a lot of <code>Form</code> (<code>public partial class Myform: Form</code>).</p>
  
  <p>Like this:</p>
  
  <pre><code>ArrayList listOfMyForms = new ArrayList();
  
  for(int i = 0; i &lt; 100; i++)
  {
     listOfMyForms.Add(new Myform());
  }
  </code></pre>
  
  <p>So.. I make 100 times object...</p>
  
  <p><strong>BUT</strong> if I delete all using remove method (call in for loop):</p>
  
  <pre><code>public void remove(Myform someForm)
  {
      listOfMyForms.Remove(someForm);
      someForm = null;
      GC.Collect();
  }
  </code></pre>
  
  <p><strong>I CAN SEE FULL MEMORY (20mb) in Visual Studio section: Diagnostic tools (Process monitor</strong></p>
  
  <hr>
  
  <p>Before creating 100 forms is memory on 16mb.</p>
  
  <p>After creating 100 forms is memory on 20mb.</p>
  
  <p><strong>After clean all forms is memory on 20mb.</strong></p>
  
  <hr>
  
  <p>So.. How can i free my memory?</p>
  
  <p>I hope, you understand my problem. Sorry for my bad english :-)</p>