*gc-after-hook*

$Revision: 5.0.2.4 $

Variable

Package: EXCL

If the gsgc switch :hook-after-gc is non-nil, then the value of this symbol, if non-nil, will be funcalled immediately after a scavenge. Thus the value should be a function that takes five arguments:

  1. a boolean which will be non-nil if the gc just completed was a global gc,

  2. a fixnum equal to the number of bytes copied to newspace,

  3. a fixnum equal to the number of bytes copied to oldspace,

  4. a fixnum which is the efficiency as a percentage (see Note 1 just below),

  5. and a fixnum which is the number of bytes that still must be allocated (see Note 2 just below).

Note 1: Efficiency is the ratio of non-gc cpu time to total cpu time.

Note 2: Garbage collections usually happen because an object must be allocated but there is not enough free space to do so. The fifth argument gives the size of not-yet-allocated objects.

The initial value of this variable is a function that implements the global gc behavior described in the next section. If you wish to change the value of this variable and preserve the global gc behavior described below, set the value of this switch to something like the following (note the use of a feature to prevent recursion if this code is run twice):

;; This form should be placed in a location (such as a file)
;; where it can be compiled.
(let ((continuation excl:*gc-after-hook*))
  (if (null (excl:featurep :my-gc-after-hook-added))
      (progn
        (push :my-gc-after-hook-added *features*)
        (setq excl:*gc-after-hook*
            #'(lambda (global new old efficiency to-be-allocated)
                 ; ... code to do what you want after a gc ....
                 (when continuation
                   (funcall continuation global new old efficiency to-be-allocated))
                  ; ... more of your code if desired ...)
       )))))

See gc.htm for more information on garbage collection and gsgc parameters.

The general documentation description is in introduction.htm. The index is in index.htm.

Copyright (C) 1998-1999, Franz Inc., Berkeley, CA. All Rights Reserved.