Objects that are known to have long life can be allocated directly in a higher generation, by using
allocation-in-gen-num
and
set-default-generation
. Note that both these functions have a global effect, that is any object allocated after a call to
set-default-generation
or within the body of
allocation-in-gen-num
is allocated in the specified generation, unless it is explicitly allocated in a different generation. Therefore careless use of these functions may lead to allocation of ephemeral garbage in high generations, which is very inefficient. Conversely, if a long-lasting object is allocated to a low generation, it has to survive several garbage collections before being automatically promoted to the next generation.
The best way to control the allocation generation for an array is to call make-array with
allocation
:long-lived
or a number.
See also Allocation of interned symbols and packages and Allocation of stacks.
LispWorks User Guide and Reference Manual - 21 Dec 2011