The Boehm's collector provides a facility that allows a function to be
called just before a memory zone is collected. The
GC_register_finalizer() takes as arguments the function to be
called when the memory zone is being collected, the address of the
memory zone, a client data that's passed to the function when it is
called together with the address of the memory zone. There two more
arguments to this function, that are used as out arguments: the old
finalizer function and the old client data. Pass NULL to these
arguments if you're not interested in their values.
Be careful with what you do in the finalizer function. In general don't assume that the finalizers are invoked in any particular order. More important don't do any memory allocation inside the finalizer function. This would case the finalizer to be invoked again which is not probably what you want (this may be a bug in the collector).
More explanation for the public functions can be found in both `gc.h' and `gc_typed.h'.
Go to the first, previous, next, last section, table of contents.