www.digitalmars.com         C & C++   DMDScript  

D - Garbage Collection

Once again, I just ran across D.  Please pardon me if I walk on toes
already trodden upon.

A couple of ideas on garbage collection.  First, many of the ideas of
"modern" garbage collectors were formed when physical memory was
much smaller than virtual memory. At the moment, however, max
memory on a x86 < $1000.  While a compacting garbage collector
may save page faults on the 486 in your basement, it doesn't
make much sense on a 2 GB machine.  Slopping crud around
wastes processor cycles that can be usedelsewhere.  Probably.

Second, it isn't necessary to stop program execution to do garbage
collection.  I havea very JVM garbage collector (OK, it's a
retro-grade mark-and-sweep [see above]) that asks each thread
to mark itself when convenient (it will mark threads known to
be stalled), then waits for all threads to report completion.  In the
meantime, objects are created marked, and assignments into objects
are marked.  The net result is that no thread stalls waiting on
garbage collection.  Furthermore, on a multi-processor, marking
of thread can take place in parallel on a multi-processor.  All
in all, the scheme takes a great deal of the pain out of garbage
collection.

I'm not going to insist that this technique is appropriate for D.  I
just want to remind folks that most thinking about garbage collection
was done for Lisp umpteen generations ago.  Before anything gets
cast in concrete, fresh thinking would be a very good thing.
Mar 21 2002