Memory leaks!
-
Hi all, I have a complicated form. I call that form from my main form and then close it. After close I call GC.Collect() to ensure that all the memory used for the form has been removed. But it still exited. I load sos.dll and use !dumpheap -stat command to show memory and see that my form and all controls and objects the form use still existed. I debug for a long time, remove delegates, dispose disposable objects etc. but the form didnt' go. So how can I know which object hold reference to the form? (they call them root reference as I remember). Any article, any tool to solve my problems. It's critical, please help me. Regards,
-
Hi all, I have a complicated form. I call that form from my main form and then close it. After close I call GC.Collect() to ensure that all the memory used for the form has been removed. But it still exited. I load sos.dll and use !dumpheap -stat command to show memory and see that my form and all controls and objects the form use still existed. I debug for a long time, remove delegates, dispose disposable objects etc. but the form didnt' go. So how can I know which object hold reference to the form? (they call them root reference as I remember). Any article, any tool to solve my problems. It's critical, please help me. Regards,
-
Hi all, I have a complicated form. I call that form from my main form and then close it. After close I call GC.Collect() to ensure that all the memory used for the form has been removed. But it still exited. I load sos.dll and use !dumpheap -stat command to show memory and see that my form and all controls and objects the form use still existed. I debug for a long time, remove delegates, dispose disposable objects etc. but the form didnt' go. So how can I know which object hold reference to the form? (they call them root reference as I remember). Any article, any tool to solve my problems. It's critical, please help me. Regards,
You can use memprofiler (mentioned in the other post) and you can also use the CLR Profiler[^] tool. You really shouldn't be calling
GC.Collect()
yourself in any case. All this does is force a garbage collection cycle to run "out of turn", which ultimately causes more work for the GC. Whenever a collection cycle runs, your applications main thread is frozen for the duration of the cycle...so the more times you force a collection, the worse your performance will become. Once you close the form, are you setting the variable reference tonull
?----------------------------- In just two days, tomorrow will be yesterday.