[Home Page] - [Reviews Main] | |
|
Garbage Collection by Richard Jones & Rafael Lins Recommended |
| ISBN: 0-471-94148-4 Publisher: Wiley Pages: 377 pages Price: £29-95 |
| Categories: advanced c++ |
| Reviewed by Francis Glassborow in C Vu 8-6 (Sep 1996) |
GC is essential for some programming paradigms, desirable
for others and detrimental to some. It is the existence of that last group
that led to C++defaulting to non- GC .
Even more important is that there are at least three pure GC
strategies, reference counting, mark and sweep, and copy and compact.
Each has definite strengths and weaknesses. Languages such as Smalltalk have
selected a strategy and, as a programmer, you have to live with it (it may
even vary from compiler to compiler which can have significant
implications).
There is nothing in C++ (nor in C) that prohibits
the use of GC and there are third party libraries that
provide GC for C++ (there is also a
conservative GC available for C, though it is
harder to provide such facilities for that language). It is also perfectly
allowable for a C++ compiler to provide GC
support.
At the Stockholm meeting of WG21/X3J16 there was a paper from
Bjarne Stroustrup on the subject of garbage collection. The motivation for
the paper was to try to build into the language a hint that GC
could be made available in C++. In the event the
suggestions were voted out, mainly, I suspect, because they did not actually
do anything except propose a macro that would allow a program to check if a
compiler was working in GC mode. Most of those present were
already completely aware that C++can support GC
and therefore saw the macro as one more unnecessary application of
the pre-processor (I know this is an over simplification but this is not the
place to get into all the technical detail).
How much do you know about garbage collection? Certainly in the early days
it was one of those processes that real time programmers avoided like the
plague because it periodically brought their program to a juddering halt
while the garbage collector recovered memory resources. These days
GC has become much more sophisticated with a multitude of
algorithms.
If you want to know about the principles, perhaps because you have an
ambition to write a garbage collecting library for C++ (you have
to replace operator new and operator delete) then
this is an excellent place to start. In fact there are many places where a
programmer wishes to manage memory allocated to some process where a sound
knowledge of GC algorithms will save many wasted hours.
One early place where you might like to experiment with garbage collection
is by providing it for managing the memory requirements of a single class via
overloaded versions of new and delete. Definitely
getting into expert territory but it would make a good series for
Overload.
Those interested in management of (dynamic) memory should read this book. To the best of my knowledge there are no competitors.
To link to this review, please use the URL: http://www.accu.org/bookreviews/public/reviews/g/g000560.htm
Copyright © The Association of C & C++ Users 1998-2000. All rights reserved.