Next: , Up: Garbage Collection   [Contents][Index]


2.7.1 GC Parameters

The following variables control the behavior of the garbage collector:

Variable: extensions:*bytes-consed-between-gcs*

CMUCL automatically GC’s whenever the amount of memory allocated to dynamic objects exceeds the value of an internal variable. After each GC, the system sets this internal variable to the amount of dynamic space in use at that point plus the value of the variable ext:*bytes-consed-between-gcs*. The default value is 2000000.

Variable: extensions:*gc-verbose*

This variable controls whether ext:gc invokes the functions in ext:*gc-notify-before* and ext:*gc-notify-after*. If *gc-verbose* is nil, ext:gc foregoes printing any messages. The default value is T.

Variable: extensions:*gc-notify-before*

This variable’s value is a function that should notify the user that the system is about to GC. It takes one argument, the amount of dynamic space in use before the GC measured in bytes. The default value of this variable is a function that prints a message similar to the following:

   [GC threshold exceeded with 2,107,124 bytes in use.  Commencing GC.]
Variable: extensions:*gc-notify-after*

This variable’s value is a function that should notify the user when a GC finishes. The function must take three arguments, the amount of dynamic spaced retained by the GC, the amount of dynamic space freed, and the new threshold which is the minimum amount of space in use before the next GC will occur. All values are byte quantities. The default value of this variable is a function that prints a message similar to the following:

    [GC completed with 25,680 bytes retained and 2,096,808 bytes freed.]
    [GC will next occur when at least 2,025,680 bytes are in use.]

Note that a garbage collection will not happen at exactly the new threshold printed by the default ext:*gc-notify-after* function. The system periodically checks whether this threshold has been exceeded, and only then does a garbage collection.

Variable: extensions:*gc-inhibit-hook*

This variable’s value is either a function of one argument or nil. When the system has triggered an automatic GC, if this variable is a function, then the system calls the function with the amount of dynamic space currently in use (measured in bytes). If the function returns nil, then the GC occurs; otherwise, the system inhibits automatic GC as if you had called ext:gc-off. The writer of this hook is responsible for knowing when automatic GC has been turned off and for calling or providing a way to call ext:gc-on. The default value of this variable is nil.

Variable: extensions:*before-gc-hooks*
Variable: extensions:*after-gc-hooks*

These variables’ values are lists of functions to call before or after any GC occurs. The system provides these purely for side-effect, and the functions take no arguments.


Next: Generational GC, Up: Garbage Collection   [Contents][Index]