Chris Mullins said:
I don't agree with that at all, really.
The scenario in their article they are repeatadly calling a bug, isn't a
GC bug at all - it's a bug in the UpDown control. That control isn't
removing an event handler, thus keeping the control rooted for way longer
than the developer intended. The GC is working perfectly. It's a great
article on "how to" for tracking down a leak though....
I've yet to come across a single instance where the GC wasn't working as
designed. Given the type of work I do - large scale, high performance,
high availability server applications - and the amount of time I spend in
profilers (both performance and memory) - I know the area pretty well.
There have been a number of times where apps were leaking memory, but in
all cases it turned out to be developer bugs. Sometimes very subtle
application bugs or race conditions, but bugs nonetheless.
In this day and age, GC is pretty good. It lets junior devs build small
apps in a "fire and forget" type of way. Unfortuantly, as complexity
grows, that "fire and forget" approach has to be replaced with a much
deeper understanding of how things work.
At the end of the day, as professional developers building complex
applications, we need to have a good understanding to how Garbage
Collection works. We need to understand Dispose patterns, Finalization,
how the Managed Heap works, and other related technologies. We need to
understand what a root path is, and how it keeps things from being
collected. At the more esoteric level, if you're building really complex
apps, you need someone around who understands how Pinning and
Fragmentation work, Weak References, Object Resurrection, the differences
between the Worksation and Server CLR, what Concurrent GC is, what the
Large Object Heap is, and all the other good struff that's in there.
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.
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.
Willy.