[plt-scheme] Memory / Garbage Collection

From: John Clements (clements at brinckerhoff.org)
Date: Mon Dec 2 12:26:59 EST 2002

On Monday, December 2, 2002, at 11:55  AM, Paul Steckler wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> Can someone describe how the garbage collector works?  I saw in the
>> documentation that it's "conservative" but I don't know what that
>> means
>> exactly.  I'm guessing that it doesn't handle structures that "point
>> to
>> themselves".  I'm developing a genetic programming tool (which
>> generates a
>> lot of temporary data) and I have a memory leak.  I'm using the
>> Windows
>> version 202.
> The conservative collector determines which potential memory references
> must be references.   In some cases, it can't distinguish memory
> references from other data.  When it guesses wrong, the actual memory
> referred to is never collected.

Just to elaborate a bit further; conservative collectors don't have any 
problem with circular data structures ("structures that point to 
themselves").  The only problem with conservative collectors is that 
they may mistake an integer for a pointer.  As a result, conservative 
collectors are unlike reference-counting schemes in that circular data 
structures can always be collected if they're not reachable.

You might also want to consider two alternatives:
1) Run your code in mzscheme (the command-line tool), and compare its 
memory usage to the numbers you're getting in DrScheme.  Of course this 
only works if your code does not use graphic primitives.
2) Look into 3m, the precise collector for PLT.

In general, the problem that you're describing does not seem 
characteristic of a problem with conservative memory collection.  This 
is just a guess, but I'd guess that your program or DrScheme is holding 
on to lots of extra memory.  To distinguish between these, you can try 
running it in mzscheme.

john clements

Posted on the users mailing list.