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 water mark. The water marks are reset after each garbage collection, and you have control over where the water marks are set to 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.
You can start the garbage collector explicitly 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.