Enabling and Disabling the Garbage Collector

The user has the option of executing programs with or without garbage collection. Procedures that do not use a large amount of heap space before backtracking may not be affected when garbage collection is enabled. Procedures that do use a large amount of heap space may execute more slowly due to the time spent garbage collecting, but will be more likely to run to completion. On the other hand, such programs may run faster when the garbage collector is enabled because the virtual memory is not expanded to the extent that "thrashing" occurs. gc/0 and nogc/0 are the built-in predicates that are used to enable and disable the garbage collector. Alternatively, the gc Prolog flag can be set to on or off. To run the gc in a verbose mode, set the gc_trace flag to on. By default, garbage collection is enabled.