Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Garbage Collection

I was just reading an MSDN article called "Garbage Collector Basics and Performance Hints".  It reminded me of Joel's articles "Law of Leaky Abstractions" and "Back to Basics".

Having just completed my first project in C#, I'm a little scared.

The article can be found at

Harold Ship
Wednesday, September 8, 2004

Why worry,

Garbage collection is very effiecient all in all. Unless your working on Doom 4 chill and concentrate on getting your algorithms spanking.

Joel 2
Wednesday, September 8, 2004

I'd say, maybe worry. We have had problems with GC in Java and though they were few relative to the amount of activity in our various JVM's they had severe effects on users and were a nightmare to diagnose

I vividly recall huge pin the blame on the vendor meetings between the hardware, application, AppServer vendors. That one ended up being a bug in the JVM, BTW).

No similar level of experience with MS's implementation yet, hopefully the Word development team had nothing to do with it.

Greg Tomkins
Friday, September 10, 2004

I've found that GC can "lock up" the application for an annoying timespan (10 seconds or more) if you allocate tons of smallish objects, keep them around for a while, then allocate tons more.

However, the solution was to explicitly all GC.Collect() at the start of the constructor that triggered most of the allocation. These collections run much faster than the one that had triggered automatically.

So I'd suggest that you test the application if automatic GC is long enough to be annoying, and find a strategic place for manual GC if so.

Chris Nahr
Friday, September 10, 2004

*  Recent Topics

*  Fog Creek Home