title: Memory not released by DataGridView?
body: <p>Guys I have a simple windows form application in C#. It only has 2 Forms. One form has only one button, while other has a <code>DataGridView</code> and one button. Please have a look at the code of both forms :</p>
  
  <p>Code of <code>Form1</code>, having one button that shows up <code>Form2</code>.</p>
  
  <pre><code>public partial class Form1 : Form
   {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void showFrom2_Click(object sender, EventArgs e)
      {
          Form2 frm2 = new Form2();
          frm2.Show();
      }
  }
  </code></pre>
  
  <p>Code of <code>Form2</code>, which has a <code>DataGridView</code> that is populated by GUID to test 10k rows at a time.</p>
  
  <pre><code>public partial class Form2 : Form
  {
      public Form2()
      {
          InitializeComponent();
      }
  
      private void populateGrid_Click(object sender, EventArgs e)
      {
          DataTable dt = new DataTable();
          for (int i = 0; i &lt; 10; i++)
          {
              dt.Columns.Add(i.ToString());
          }
          for (int j = 0; j &lt; 10000; j++)
          {
              DataRow row = dt.NewRow();
              for (int k = 0; k &lt; 10; k++)
              {
                  row[k] = Guid.NewGuid().ToString();
              }
              dt.Rows.Add(row);
          }
          dataGridView1.DataSource = dt;
      }
  
      private void closeForm2_Click(object sender, EventArgs e)
      {
          dataGridView1.Dispose();
          this.Close();
      }
  </code></pre>
  
  <p>Now whenever I populate <code>DataGridView</code> and then close the <code>Form2</code>. The memory is not released. If I keep populating the grid and closing the <code>Form2</code> "MULTIPLE" times without closing the whole application, my system runs out of memory (I have 1 gb of RAM). Upon calling <code>dataGridView1.Dispose();</code> shouldn't <code>GarbageCollector</code> do his job and free the memory?</p>
  
  <p>What I want is that whenever I close the <code>Form2</code>, the memory should be freed up in the system.</p>
  
  <p>Note : I am monitoring the memory through <code>TaskManager</code> (I know it doesn't display the correct amount of memory consumed but it doesn't matter anyway as I run out of memory if I keep populating the grid. The memory is not being release). I even tried to call <code>GC.Collect()</code> on the close button (Which is not a good call and it didn't help either).</p>
  
  <p>Also, I would appreciate if someone could tell me how to monitor the "real" consumption by an app. I read somewhere that you use .Net performance counter. What is that?</p>
  
  <p>P.S. Don't ask why I am populating the grid with 10k rows. I am just doing it for testing purpose.</p>