All Manuals > LispWorks® User Guide and Reference Manual > 47 The SYSTEM Package

marking-gc Function

Summary

Performs a Marking GC in 64-bit LispWorks.

Package

system

Signature

marking-gc gen-num &key what-to-copy max-size max-size-to-copy fragmentation-threshold

Arguments
gen-num
An integer in the inclusive range [0,7].
what-to-copy
One of the keywords :cons, :symbol, :function, :non-pointer, :other, :weak, :all or :default.
max-size
A synonym for max-size-to-copy.
max-size-to-copy
A positive number or nil.
fragmentation-threshold
A number in the inclusive range [0, 10].
Description

The function marking-gc garbage collects (GCs) the generation specified by gen-num, and all younger generations. It uses mark and sweep, rather than copy.

Mark and sweep garbage collection uses less virtual memory during its operation, but leaves the memory fragmented, which has a detrimental effect on the performance of the system afterwards. It is therefore not used automatically by the system, except to garbage collect static objects.

marking-gc is useful when you want to GC a generation which contains large amount (gigabytes) of data, to make sure there are no spurious pointers from this generation to a younger generation, and you do not expect many objects in the large generation to be collected. In this scenario, a Copying GC would use virtual memory which is almost double the size of the large generation during its operation, and so would possibly cause heavy paging.

Marking GC causes fragmentation. You can reduce the amount of fragmentation by supplying either (or both) of the arguments what-to-copy and max-size-to-copy. These specify that part of the data should be collected by copying instead. Using some copying GC rather than mark and sweep will reduce the amount of fragmentation.

what-to-copy specifies the allocation type to copy. It can be one of the main allocation types or :weak, meaning copy only objects in segments of that type. what-to-copy can also be :all, meaning copy objects in all segments. If what-to-copy is :default then each call to marking-gc chooses one of the main allocation types or :weak to copy, and successive calls with :default cycle through these allocation types.

max-size-to-copy (or max-size) can be used to limit the amount that is copied, and thus limit the virtual memory that the operation needs. If max-size-to-copy is non-nil, it specifies the limit, in gigabytes, of memory that can be used for copying. If there is more than max-size-to-copy gigabytes of data of the type what-to-copy, the rest of this data is garbage collected by marking. The default value of max-size-to-copy is nil, which means there is no limit on the amount that is copied.

fragmentation-threshold should be a number between 0 and 10. It specifies a minimum ratio between the free area in a segment that cannot be easily used for more allocation and the allocated area in this segment. Segments that are below this threshold are not copied. The default value of fragmentation-threshold is 1.

Notes

marking-gc is implemented only in 64-bit LispWorks. It is not relevant to the Memory Management API in 32-bit implementations.

In the Mobile GC, marking-gc is equivalent to (gc-generation gen-num).

See also

gc-generation
set-blocking-gen-num
11.2 Guidance for control of the memory management system


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:31:02