title: A Winform program so simple -- but may I have my memory back?
body: <p>I decided to do a simple Windows Form project with .NET 2.0 in C# to test and see what exactly is causing what seems to be 'growing memory leaks' in my other main UI application.</p>
  
  <p>What I did in this simple project was create two forms: Form1 &amp; Form2</p>
  
  <p>Form1 has one big button that pops up a new instance of Form2.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      Form2 fm2 = new Form2();
      fm2.ShowDialog();
      fm2.Dispose();
  }
  </code></pre>
  
  <p>And Form2 does nothing, except show itself, until the user decides to close the window.</p>
  
  <p>Now when I start the application and I press the button on Form1, I get a jump in memory usage of about 100~kb. I would close the pop-up, press the button again, and see another 100~kb increment. I would do about 10-20 iterations of this. In the end, I would see a jump from 6,880 KB -> 8,684 KB in the task manager. Now, it would eventually stop at a certain number (8684 KB in this case). After it reaches this, it would no longer increase.</p>
  
  <p>Here is my problem:</p>
  
  <p>My main UI application is obviously a lot more complex than this and if anything, this type of memory increase most likely only accounts for a portion of the overall memory increases I'm seeing. Nonetheless, it's still noticeable, and in a project with many forms, this would look very bad in the task manager, because it looks like a memory leak.</p>
  
  <p>So first of all, is this a memory leak?</p>
  
  <p>Secondly, even if it wasn't, is there any way to prevent this?</p>