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.
Re: GC and C++
by HanSoft on Thu 29th Apr 2004 09:03 UTC

> 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

Very true! GC programmers tend to think that for every single bit of information, you have to do an allocation. Well, I don't (like) to do OO and even less GC, just for the reason that it breeds BAD programming habits.

Any real good C programmer knows that you estimate the size
of any 'object' and then do the allocation in one chunk. If you can't (because it is too large) you do another algorithm, but you're not gonna fragment your memory. If it is memory conservation over speed you can do a realloc(). If not, who cares.

For my own compiler, I estimate the size of the objectcode during tokenizing, so don't say it can't be done. If you really can't tell where you're going you can always use the 'increase allocation' technique, where you start allocating a chunk (say 10K) and every other allocation is increased by a certain percentage (say 50%), so the next allocation is 15K.

However, this depends on the problem you have to solve. I doubt very much that an OO/GC programmer can beat the speed of my C programs. That doesn't mean that there is no niche for GC languages, but don't say they're more efficient: they're not and they never will be!

Still beats me that someone can 'forget' what he allocated..