7.13 Garbage collection

Care must be taken about proper interaction with the Oz garbage collector: it does not notice if you store an OZ_Term into a global C variable. Therefore it will free the space on the heap occupied by this term, which leads to memory faults. Oz provides functions to explicitly inform the garbage collector about external references to the heap.

OZ_protect

int OZ_protect(OZ_Term *tp)

During garbage collection the term tp points to is visited and may be moved. Therefore tp must be a pointer to a term. The location where tp points to is modified by the garbage collector.

OZ_unprotect

int OZ_unprotect(OZ_Term *tp)

This is the inverse function to OZ_protect informing the garbage collector that the reference to the heap is no longer used.


Michael Mehl, Tobias Müller, Christian Schulte and Ralf Scheidhauer
Version 1.0.1 (19990218)