GC.Collect() not cleaning memory, how to find out what references to lots of
memory still exist?
When all my processign is done i set everything to null and then:
GC.Collect();
and then
GC.WaitForPendingFinalizers();
but it still shows that my process takes 400 MB of memory. Is there any easy
way to see what references that I forgot to set to null so that the memory
cleas up on GC.Collect() ?
Henning Krause [MVP - Exchange] - 15 Apr 2008 22:48 GMT
Hello,
in 99% of the time, you should not call GC.Collect. In many cases this will
actually decrease performance as you distort internal statistics of the GC.
Take a Profiler (SciTech Memory profiler is what I use when troubleshooting
memory problems; They actually have a 30 days trial; http://www.scitech.se/)
and examine where the root references of your objects are.
Kind regards,
Henning Krause
> GC.Collect() not cleaning memory, how to find out what references to lots
> of memory still exist?
[quoted text clipped - 6 lines]
> easy way to see what references that I forgot to set to null so that the
> memory cleas up on GC.Collect() ?
Barry Kelly - 16 Apr 2008 00:24 GMT
> GC.Collect() not cleaning memory, how to find out what references to lots of
> memory still exist?
[quoted text clipped - 6 lines]
> way to see what references that I forgot to set to null so that the memory
> cleas up on GC.Collect() ?
BTW, WinDbg combined with SOS can find your roots too, for free. Rico
Mariani did an interesting presentation and some blog posts about it:
http://www.google.com/search?q=rico+mariani+windbg+sos+root
Here's one post:
http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx
-- Barry

Signature
http://barrkel.blogspot.com/
Peter Duniho - 16 Apr 2008 01:57 GMT
> [snip]
Please stop multi-posting. You've only been told dozens of times already
not to do that, and you refuse to stop it.
Why anyone answers your questions at all, given your unwillingness to
cooperate and treat the newsgroups more respectfully, is beyond me. Maybe
they just aren't aware that you post these questions in multiple
newsgroups, causing readers of each newsgroup to wind up answering the
questions independently, wasting everyone's bandwidth and time.
Hopefully that will change.
Barry Kelly - 16 Apr 2008 05:40 GMT
> > [snip]
>
> Please stop multi-posting. You've only been told dozens of times already
> not to do that, and you refuse to stop it.
I didn't know he's been repeatedly doing that. PLONK etc...
-- Barry

Signature
http://barrkel.blogspot.com/