| Allegro CL version 10.0 Unrevised from 9.0 to 10.0. 9.0 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:
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.
Because the amount of free space needed (as specified by the last
returned value) must be available, modifying the amount of free space
in newspace as a side effect of executing *gc-after-hook*
code is dangerous. Lisp
can fail if there is in fact inadequate free space to allocate the
object whose allocation triggered the gc. This means the code should
not cons (or should minimally cons) and should not reduce the size of
newspace with, for example, a call to resize-areas. While there may be cases where
a carefully coded call to resize-areas in a gc after hook is
appropriate, the rule of thumb is do not call that function.
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)) (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 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-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 9.0 page.
Created 2015.5.21.
| Allegro CL version 10.0 Unrevised from 9.0 to 10.0. 9.0 version |