[gclist] What to say about GC.

Roy Ward roy@earthlight.co.nz
Fri, 26 Jul 1996 05:13:54 +1200


>I recently had a battle with a bug that illustrates both sides of the
>arguments
>here.

[snip]

>I know which class of symptoms *I'd* like to work with!  GC may not be
>perfect,
>but at least it maintains the program's abstractions.  Stores through dangling
>pointers don't.
>
>For the record, tracking this down took over 3 weeks - by far the longest time
>I've ever spent on one bug in the almost 25 years I've been programming.
>(Have
>I lived a charmed life?)  For reasons that I can't explain, *none* of the
>tools
>I tried (Purify, Sentinel, the Solaris debugger's memory tracing facility)
>were
>able to deal successfully with the code involved - a big, hairy,
>multi-threaded
>server - either dieing in unpleasant ways or just failing to start.

On the other side of the coin, a few years ago, I was writing a symbolic algebra
program in a language that was still under development, and I found that my
program would run fine for about an hour, then it would crash in an obscure way
after a GC. Because the bug was in the GC, it was quite difficult to track down
(particularly as my code would run for a while after the GC with erroneous
values). Luckily I was eventually able to reproduce the problem with a very
simple program, and so it was tracked down and fixed. That was one of many
problems with that GC.

Of course, less time was spent fixing that that I have probably spent over the
years tracking down all my memory problems while I'm working in languages like
Pascal, C, C++ (ugh!).

The sort of behaviour above has possibly give GC a very bad name with those
who have had that sort of trouble. When I came to design a language, I
remembered
all the GC hassles I'd run into, and ended up not using traditional GC at all
(I simply maintain only one reference to each object, and if I want another
reference, I make a copy, so all functions can clean up safely by destroying all
their arguments). Not that I think that this is at all efficient, just I want to
have memory taken care of without having to write a full GC. I'll look at adding
GC later, when I have good tools to write it, and better debugging tools.

When GC is good, it is very very good, but when it is bad it is horrid!

Roy Ward
--
Moderation in all things? Over my dead body!