NextPrevUpTopContentsIndex

mark-and-sweep

Function
Summary

Garbage collects a specified generation.

Package

hcl

Signature

mark-and-sweep gen-number => bytes

Arguments

gen-number

0 for the most recent generation, 1 for the most recent two generations, and so on up to a maximum (usually 3). Numbers outside this range signal an error.

Values

bytes

The number of bytes allocated in that generation.

Description

mark-and-sweep is used to garbage-collect a specified generation of storage (and all lower generations). A call to this function forces the garbage collector to scan the specified generations. This can be of use in obtaining consistent timings of programs that require memory allocation. Alternatively, performance can sometimes be improved by forcing a garbage collection, when it is known that little memory has been allocated since a previous collection, rather than waiting for a later, more extensive collection. For example, the function could be called outside a loop that allocates a small amount of memory.

It is specially helpful to mark and sweep generation 2 when large, long-lived data structures become garbage, because by default it is never marked and swept. The higher the generation number the more time the mark-and-sweep takes, but also the more space recovered.

Examples
(mark-and-sweep 0)  ; collect most recent generation (mark-and-sweep 3)  ; collect all generations
See also
avoid-gc
block-promotion
get-gc-parameters
gc-if-needed
normal-gc
set-array-weak
set-gc-parameters
set-hash-table-weak
without-interrupts
with-heavy-allocation

LispWorks Reference Manual - 23 Jul 2004

NextPrevUpTopContentsIndex