[plt-scheme] Memory management and MzScheme

From: Anton van Straaten (anton at appsolutions.com)
Date: Sat Nov 23 18:48:23 EST 2002

> Thank your for the reply. I did poke around MzScheme's sources
> and as far as I could tell scheme_build_list will take its input
> and create a list by copying the input into pairs. I did not
> see anything in the code that implied the need for specially
> allocated memory.

scheme_build_list would copy the string pointers into pairs, and once that
has actually happened, your strings ought to be safe.  However, if garbage
collection is triggered before that happens - e.g. from within
scheme_make_string or scheme_build_list itself - the strings whose pointers
have not yet been copied into a Scheme structure would be fair game for the
garbage collector.

Note that you wouldn't see the garbage collection being invoked directly
from within the above functions; instead, it would be invoked from within
memory allocation functions which those functions use.

I don't know exactly what conditions trigger garbage collection in MzScheme,
but since your loop allocates 10,000 objects, it seems reasonable that
collection would occur at least once during that process.


Posted on the users mailing list.