REDUCE

16.5 Garbage Collection

(reclaim): nil expr
Reclaim is the user level call to the garbage collector. Active data in the heap is made contiguous and all tagged pointers into the heap from active local stack frames, the binding stack and the symbol table are relocated. If *gc is t, prints some statistics. Increments gcknt* and updates gctime*.

(known-free-space): integer expr
Returns the number of items available in the heap.

(free-bps): integer expr
Returns the number of items available in the BPS (Binary Program Space).

*gc = [Initially: t] switch
   
*Gc controls the printing of garbage collector messages. If nil no indication of garbage collection occurs. If non-nil various messages will be displayed.
    1 lisp> (reclaim)  
    ⋆⋆⋆ Gargabe collection starting  
    ⋆⋆⋆ GC 1:  8-Nov-97 15:49:54, 50 ms (50 %), 218 recovered, 260679 free  
    nil

As the example shows, the amount of time (in milliseconds), required to do the garbage collection, the number of items recovered, and the number of items available in the heap are displayed. The first number which follows GC represents the value of gcknt*. The inclusion of the date into the message has been found useful for calculations which take extremely long.

gctime* = [Initially: 0] global
   
The total time (in milliseconds) spent in garbage collection. When the garbage collector is invoked, the time spent performing the collection is added to the value of gctime*

gcknt* = [Initially: 0] global
   
Records the number of times that the garbage collector has been invoked. Gcknt* may be reset to another value to record counts incrementally, as desired.