[racket] writing garbage collector in racket/scheme?

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Fri Oct 8 21:16:01 EDT 2010

On Fri, Oct 08, 2010 at 11:49:27AM -0700, YC wrote:
> Hi all -
> I have a rather curious question - is it possible to write a garbage
> collector in a pointerless language such as racket/scheme?

It is necessary to limit the amount of dynamic storage the garbage 
collector churns through by its own execution so that it is less than 
the storage it manages to recycle.

If it manages to work only with live storage, and never examines dead 
storage cells in any intensive way, it should work.

That said, you'll still need a mechanism to access the underlying 
storage model.

I once wrote a garbage collector whose code was in the garbage-collected 
heap.  That is, the garbage collector managed to garbage-collect its own 
code.  If I had installed a new collector to replace the old one, the 
new one would have freed the storage used by the old one's code.  
(Actually, I should have done that as a test case...)

-- hendrik

Posted on the users mailing list.