title: C# Garbage Collection in windows forms
body: <p>I have 2 windows forms frmMain &amp; frmDialog. When I click a button on frmMain, frmDialog opens. Here is my code for the click event of the button:</p>
  
  <pre><code>frmDialog f2 = new frmDialog();
  
  f2.Show();
  </code></pre>
  
  <p>When I keep on clicking the button, new forms appear &amp; <strong>don't close</strong>. An object gets garbage collected when it goes out of scope.</p>
  
  <p><strong>My question is:</strong> </p>
  
  <p>Why doesn't variable f2 get garbage collected when it goes out of scope?</p>
  
  <p>Is it a memory leak?</p>