Groups | Blog | Home
all groups > dotnet ado.net > april 2008 >

dotnet ado.net : GC.Collect() not cleaning memory, how to find out what references to lots of memory still exist?


DR
4/15/2008 2:03:04 PM
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() ?

Scott M.
4/15/2008 7:32:18 PM
Calling GC.Collect is a bad idea is all but the most severe cases. In real
practice, you should not use it as it can actually impede your application's
performance.

Your best bet is to look carefully at the objects you are using and make
sure that, where appropriate, you call Dispose on them.

-Scott


[quoted text, click to view]

Cor Ligthert[MVP]
4/16/2008 5:31:59 AM
DR,

Why you call GC.Collect? It is the same practise as power down your computer
after your program is done and than start again.

The benefit is the same, because with letting memory unused is nothing wrong
as long as there is enough. It is better to clean it up at the right time by
instance as there is not enough memory anymore or the computer is in a kind
of idle state. And that is where Net is for.

So the parallel with power down your computer is no joke, it is exactly the
same.

Cor




"DR" <softwareengineer98037@yahoo.com> schreef in bericht
news:uOkNbC0nIHA.2292@TK2MSFTNGP03.phx.gbl...
[quoted text, click to view]
Miha Markic
4/20/2008 10:57:45 AM
Hi,

The best way would be to use an allocation profiler (i.e. AQTime) - it is
the only reliable way to look for memory leaks.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

[quoted text, click to view]
AddThis Social Bookmark Button