Go to the first, previous, next, last section, table of contents.


Boehm's garbage collector

Starting with version 0.9.0 libFoundation comes with support for the Boehm's garbage collector. It is available from

http://reality.sgi.com/employees/boehm_mti/gc.html

It is a conservative garbage collector that works by replacing the system memory allocation routines (malloc/calloc/realloc) with the ones that come with the collector. The memory allocation works as before, you allocate memory using the GC_malloc() function instead of malloc(), GC_calloc() instead of calloc() and GC_realloc() instead of realloc(). The difference comes from the fact that you're no longer required to call a free function. The collector takes care of no longer reachable portions of the allocated memory by monitoring the memory allocation of your program and trying to collect the garbages when certain conditions are met. You can also explicitly invoke the collection the garbages by calling the GC_collect() function.

The collection can also occur in another thread on systems that support multi-threading. You can disable the collection in the main thread by setting the value of a variable (GC_dont_gc) and invoke the collection in a separate thread when you wish, perhaps on a time basis or when some other conditions are met.

Another feature is that the collection can be done incrementally, ie not all the memory is collected at once. This can be done by calling the GC_collect_a_little() function. One can use this feature in the program's run loop of an interactive program to make sure the collection will not make the program stop while the collection is in progress.

Memory allocation functions are described in `gc.h'.


Go to the first, previous, next, last section, table of contents.