How to release memory used by child forms in multi form c# app?
Hello all, I really hope that here i can find some help, tnx.
I`m building a multi form c# application it has lots of forms opened in a parent form. The problem is that when i open a child form memory jumps from 15MB to 20MB, i close that child form memory stays on 20MB, i open same form again memory jumps to 25MB, etc. same goes for other forms so my question is how can i optimize memory usage of my application (how can i release the memory used by my forms when i close them).
I hope some1 will find a bit of his time to help me tnx.
Sam HobbsPosted Nov 19, 2009, 3:45 PM
The Task Manager works correctly the way it is designed to be used. It was not designed as a programming diagnostic tool. It can be used for that but we need to know what it is and is not capable of. The following articles will help you. I am sorry that there is so much to read, but there are not simple answers. It is important that developers understand these things. For most of us, most of the time we don't need to worry about memory use by C# but when memory use is a concern, we must spend some time understaning the use of memory.
Milan PandurovPosted Nov 18, 2009, 12:06 PM
Sam HobbsPosted Nov 18, 2009, 9:02 AM
Milan PandurovPosted Nov 18, 2009, 7:59 AM
Nilanka DharmadasaPosted Nov 18, 2009, 12:38 AM
When you dispose an object in becomes unavailable to you. But the memory is still allocated until the next GC cycle.
So you will have to collet GC.Collect() after disposing the objects.
But cannot gurantee the outcome of calling that method. :)
If you find this useful, please do not forget to mark as accepted.
Milan PandurovPosted Nov 17, 2009, 2:15 PM
Kirtan PatelPosted Nov 17, 2009, 1:00 PM
Close the Form By
this.Dispose();
instead of this.Close();
let me know if problem solved or not :)
if it helps you then check "Do you like this answer check box " :)