Memory Allocation/Garbage Collection



next up previous
Next: ProsCons and Up: libscheme Architecture Previous: Error Handling

Memory Allocation/Garbage Collection

The libscheme library uses Hans Boehm and Alan Demers' conservative garbage collector [1]. It provides a replacement for the C library function malloc() called GC_malloc(). The storage that is allocated by GC_malloc() is subject to garbage collection. The collector uses a conservative approach, meaning that when it scans for accessible objects it treats anything that could possibly point into the garbage collected heap as an accessible pointer. Therefore, it is possible that an integer or a floating point number that looks like a pointer into this area could be treated as a root and the storage that it points to would not be collected. In practice, this rarely happens.

Users of libscheme can use the garbage collector in their own program and are strongly encouraged to make use of it when extending libscheme. Normally the user can simply call scheme_alloc_object() to allocate a new Scheme_Object, but occasionally other types of objects need to be allocated dynamically.

The Boehm/Demers collector is freely available and can run on most any 32-bit Unix machine.



Brent Benson
Mon Sep 19 16:03:14 EDT 1994