Garbage collection

B-Prolog incorporates an incremental garbage collector for the control stack and the heap. The garbage collector is active by default. Users can disable it by setting the Prolog flag gc to off:
      set_prolog_flag(gc,off)

The garbage collector is invoked automatically to reclaim the space taken by garbage in the top-most segment when the top of the heap or the top of the stack hits the current watermark. The watermarks are reset after each garbage collection, and users have control over the values to which the watermarks are set by changing the Prolog flag gc_threshold. In general, the larger the threshold is, the more frequently garbage collection is called. The default threshold is set 100.

Users can start the garbage collector by calling the following built-in predicate:

      garbage_collect
and can check the number of garbage collections that have been performed since the system was started by using statistics/0 or statistics/2.



Neng-Fa Zhou 2013-01-25