Previous: , Up: Garbage Collection   [Contents][Index] Sweeping the Heap

After all found objects have been marked, the heap is swept.

The storage for strings, vectors, continuations, doubles, complexes, and bignums is managed by malloc. There is only one pointer to each malloc object from its type-header cell in the heap. This allows malloc objects to be freed when the associated heap object is garbage collected.

Function: static void gc_sweep ()

The function gc_sweep scans through all heap segments. The mark bit is cleared from marked cells. Unmarked cells are spliced into freelist, where they can again be returned by invocations of NEWCELL.

If a type-header cell pointing to malloc space is unmarked, the malloc object is freed. If the type header of smob is collected, the smob’s free procedure is called to free its storage.