I have a big winform class that calls from a little one like this:
void login()
{
mainForm f1 = new mainForm();
f1.ShowDialog();
}
The mainForm will take lots of memory after login (I check it in Task Manager). After closing the mainForm, program returns to login form. At this step I check Task Manager again and see that my program has not released the memory that mainForm used. And after some login, my program crashes and shows “Out of Memory” error.
I have to say that I tested f1.Dispose(), f1=null, GC.Collect() and every other methods that I found.
It will only releases the memory when I close the login form (Its the starting class used in Application.Run)
I want to destroy the mainForm instance (f1) and all resources of this form just like when I close the program.
Couple of thoughts:
usingstatement