VariablePackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version


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

  1. a boolean which will be true 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 Global garbage collection in gc.htm and in the description of *global-gc-behavior*. The function is named by the internal symbol excl::default-gc-after-hook. 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.
;; The inital value of excl:*gc-after-hook* is a function named by
;; the symbol excl::default-gc-after-hook but we bind the value
;; to allow for an already modified function whose behavior
;; is being preserved.
(let ((continuation excl:*gc-after-hook*))
  (if (null (excl:featurep :my-gc-after-hook-added))
        (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 also gc.htm for general information on garbage collection Allegro CL, including information on gsgc switches and parameters. See section Global garbage collection in that document for information on global garbage collection.

Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version