Linked by Zachary Pinter on Tue 27th Apr 2004 17:09 UTC
General Development Garbage collection (GC) is a technology that frees programmers from the hassle of explicitly managing memory allocation for every object they create. Traditionally, the benefit of this automation has come at the cost of significant overhead. However, more efficient algorithms and techniques, coupled with the increased computational power of computers have made the overhead negligible for all but the most extreme situations.
Permalink for comment
To read all comments associated with this story, please click here.
GC and C++
by Solar on Wed 28th Apr 2004 06:49 UTC

> Traditionally popular programming languages, such as
> C/C++, require the programmer to “micro-manage” memory
> consumption.

Traditionally, programmers coming from GC languages have a hard time to grasp the concept that, if you start to write destructors for every C++ class or have numerous "new()"s in your source, your design is broken. In over 90% of the cases, you have no need to use anything but automatic variables and default destructors.

And I like to know when my cleanup functions are called: when the object leaves scope, instead of some time when the GC fires, or never (as might be the case in Java). That allows me to do meaningful things in destructors.

That being said, note that it's quite easy to "defeat" garbage collectors. One example for Java: Forget to unregister your event handlers before you release a widget, and you got a memory leak.

GC's are nice, but I prefer them to be *optional*.