An integer between 0 and 7, inclusive, or the keyword
:blocking-gen-num
.
A generalized boolean.
A generalized boolean.
An integer between 0 and 7, inclusive, or one of the keywords
:blocking-gen-num
and
:all
.
The function
gc-generation
does a Copying garbage collection (GC) on generation
gen-num
. This means it also GCs all the lower generations.
If
gen-num
is an integer, then this names the generation to collect. If
gen-num
is
:blocking-gen-num
, then this means collect the blocking generation.
By default
gc-generation
operates on the live objects in generation
gen-num
and all lower generations at or above the generation specified by
block
by copying them inside their current generation, and it operates on the live objects in generations lower than
block
by copying them to the next higher generation.
If
promote
is non-
nil
, the live objects in generation
gen-num
are also promoted to the next generation. That is the same operation that happens when the GC is invoked automatically. The default value of
promote
is
nil
.
If
coalesce
is non-
nil
, all non-static live objects in lower generations are promoted to generation
gen-num
. That is what clean-down does (with
gen-num
being the highest generation). It may be useful directly in some cases. The default value of
coalesce
is
nil
.
block
specifies a generation number up to which to promote. An integer value specifies the generation number. If
block
is
:blocking-gen-num
, then
gc-generation
promotes up to the blocking generation. If
block
is
:all
, then
gc-generation
promotes nothing. The default value of
block
is
:blocking-gen-num
.
gc-generation
is useful when you know points in your application where many objects tend to die, or when you know that that application is less heavily loaded at some time. Typically many objects die in the end (or beginning) of an iteration in a top level loop of the application, and that is normally a useful place to put a call to
gc-generation
of generation 2 or generation 3. If you know a time when the application can spend time GCing, a call to
gc-generation
with a higher value of
gen-num
may be useful. It is probably never really useful to use
gc-generation
on generation 0 or 1.
To decide on which
gen-num
to call
gc-generation
, check which generation gets full by making periodic calls to room.
gc-generation
with
promote
or
coalesce
may also be useful to move objects from the blocking generation to higher generations, which does not happen automatically (except when saving the image). For example, after loading a large amount of code, and before generating any data that may die shortly, assuming the blocking generation is 3, it may be useful to do:
(gc-generation 4 :coalesce t)
to move all (non-static) objects to generation 4, where they will not be touched by the GC any more (except following pointers to younger generations).
In 32-bit LispWorks,
gc-generation
simply calls
mark-and-sweep
. This has a similar effect, but two significant differences must be noted:
gc-generation
promotes the young generations, so repeated calls to
gc-generation
will promote everything to generation
gen-num
or generation
block
(whichever is lower).
mark-and-sweep
never promotes.