Memory Management in Windows Forms Application : Loading and Closing Forms
<p>This is my first time asking on a forum... An advanced apology if I'm too detailed...</p>

<p>I have created a program that loads some forms (like a menu for a system) and a part of the program (a form) displays the contents of a table in a database in a listview (this part is working fine). When I access that form at the start of the program, it finishes loading for about 4-5 seconds.</p>

<p>Here's the problem... When I access parts of the program a lot of times (e.g. going back and forth around two forms) then I access the form that displays the table, the loading gets slower...</p>

<pre><code>        InitializeComponent();
        //I just did this to travel back and forth to two forms easier...
        if (MessageBox.Show("", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.OK)
        {
            Form2 f = new Form2();
            this.Hide();
            f.ShowDialog();
            this.Dispose();
            //this.Close();   //I'm not exactly sure which one to use here... but whichever I use, I get same results.
        }
        //there's another one of this in the first form... 
        //so they loop to each other until i press cancel...
</code></pre>

<p>When I focused on the messagebox and pressed 'enter' for some time (dunno... about 30 seconds to 1 minute) and access the form that displays the table. it loads very slowly. (there's a progressbar to see how long I have to wait. i waited for about 1 minute for it to load when I pressed 'enter' for about 2 minutes)</p>

<p>Also, like what is seen on the code, I'm not sure the difference between Dispose() and Close() on a form (if there is one). From what I've read, Dispose() ...well... disposes the memory allocation of the object it is used on. I'm not sure, but i think Close() does this as well...</p>

<p>What should I do to improve performance?</p>
