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, i.e. 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.
Interned symbols (and their symbol names) are treated in a special way, because they are assumed to have a long life. They are allocated in the generation specified by
*symbol-alloc-gen-num*
, which defaults to 2.