This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: conservative gc


On Tue, 7 Jul 1998, Klaus Schilling wrote:

> 
> In the last posts, it was said repeatedly that the garbage collection of guile
> is conservative.
> 
> What does this mean? Is this related to conservation laws in physics (mass,
> energy, momentum etc.) Is 'mark and sweep' necessarily conservative?

ObDisclaimer: I'm not a GC programmer; I just play one on the Internet.

'conservative' means that the GC scans the stack and heap for anything
that might be a pointer, and preserves all the data thus pointed to. This
is generally done when the GC doesn't have type information for the data;
it only has a series of words of memory to work with.

Basically, it reads every word as a pointer (whether or not it is), and if
it resolves to a valid memory address, it's asssumed to be a pointer to
that memory.

This may result in the GC saving data that could be deleted (which can
waste memory), but will never result in data being prematurely deleted
(which would really screw things up).

I think 'mark and sweep' is not necessarily conservative.

> What alternatives would there be to conservative garbage collection?

If, when scanning the stack and heap, you can determine data types, you
can then preserve only those things pointed to by pointers, and free
objects only "pointed to" by floats and integers. This lets you free
*exactly* those objects that are unreferenced - no more, no less. 

Outside of GC, there's also explicit deleting (a la
C) and reference counting. I don't know of any other methods.

Hope this is helpful.

Eric