Re: GC.Collect can be trusted?
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Wed, 25 Apr 2007 10:49:24 +0200
"Christopher Ireland" <cireland@xxxxxxxxx> wrote in message news:3F2E0FCE-6917-4D3F-AB6A-CFC5FA43CFFD@xxxxxxxxxxxxxxxx
Willy Denoyette [MVP] wrote:Note also, that this article was written years ago, and is based on
the first version of the framework and never updated since then.
These are the kind of "look how great our product is, it can even
find bugs in MSFT's products" articles, but they did not find
anything, this bug was known at the time they ran the profiler, all
they did was illustrate the impact of a bug in the Windows.Forms code
on the allocation pattern.
So it was a bug in the GC then?
No, as I said, it was a bug in the Windows.Forms code.
You won't be able to find these kind of "bugs" using just a profiler,
you need a debugger, a great deal of understanding how the GC and the
CLR works, a lot of experience in debugging complex systems plus
quite some luck to finds small leaks like these. Granted, a profiler
is something you need in your toolbox, it's a great tool to
illustrate performance behaviors and uncover possible bottlenecks, it
can help you better understand your object allocation patterns, where
you allocate too many or to large objects, so you can adapt your
algorithms and allocation needs, but you won't ever be able to detect
small managed memory leaks by using a profiler alone.
I can tell you now that I have very little time to spend tracking down bugs in the GC. What I'm after is being able to track down memory leaks that I unwittingly create in the code I write. The question is: are the bugs I introduce into my code through the allocation of too many or too large objects really "memory leaks" (please, this is not a trick question, I'm really trying to figure out what's going on here :-) ?
Again, you don't have to, nor can you even track down bugs in the CLR's code like the GC, not because you don't have the time to do so, but because you are missing what I call essential when debugging a complex system like the CLR, it's the source code and a deep understanding of the internals of the CLR and the underlying platform. This is something you have to leave to the CLR team at MS, really.
Allocating too many and/or too large objects ( too complex and/or too large object hierachy) is basically a design mistake , which can possibly lead to runtime errors and/or bad performing applications (that is, it becomes a bug), but they are no leaks. Note, that while such applications can fail on some systems, they can perfectly run on system that have a lot of memory/cpu resources available. Involuntarily keeping object references alive when done with them is a latent bug, you can recover from, not a real leak.
A "real" leak is something you can't recover from, for example, an object that stays allocated in the heap, despite you no longer have live references to it in your code, there is little you can do about this and when it happens it will go undetected, unless it happens regularly in a long running process.
Willy.
.
- Follow-Ups:
- Re: GC.Collect can be trusted?
- From: Christopher Ireland
- Re: GC.Collect can be trusted?
- References:
- GC.Collect can be trusted?
- From: Ward Bekker
- Re: GC.Collect can be trusted?
- From: Ward Bekker
- Re: GC.Collect can be trusted?
- From: mpetrotta@xxxxxxxxx
- Re: GC.Collect can be trusted?
- From: Willy Denoyette [MVP]
- Re: GC.Collect can be trusted?
- From: mpetrotta@xxxxxxxxx
- Re: GC.Collect can be trusted?
- From: Willy Denoyette [MVP]
- Re: GC.Collect can be trusted?
- From: Chris Mullins [MVP]
- Re: GC.Collect can be trusted?
- From: Christopher Ireland
- Re: GC.Collect can be trusted?
- From: Chris Mullins [MVP]
- Re: GC.Collect can be trusted?
- From: Willy Denoyette [MVP]
- Re: GC.Collect can be trusted?
- From: Christopher Ireland
- GC.Collect can be trusted?
- Prev by Date: Re: Active Directory query doesn't work...
- Next by Date: Re: GC.Collect can be trusted?
- Previous by thread: Re: GC.Collect can be trusted?
- Next by thread: Re: GC.Collect can be trusted?
- Index(es):
Relevant Pages
|