Previous Chapter Next Section Table of Contents Glossary Index

Chapter 16. Understanding and Configuring the Garbage Collector

16.1. Heap space allocation

Release 0.10 or later of CCL uses a different memory management scheme than previous versions did. Those earlier versions would allocate a block of memory (of specified size) at startup and would allocate lisp objects within that block. When that block filled with live (non-GCed) objects, the lisp would signal a "heap full" condition. The heap size imposed a limit on the size of the largest object that could be allocated.

The new strategy involves reserving a very large (2GB on DarwinPPC32, 1GB on LinuxPPC, "very large" on 64-bit implementations) block at startup and consuming (and relinquishing) its contents as the size of the live lisp heap data grows and shrinks. After the initial heap image loads and after each full GC, the lisp kernel will try to ensure that a specified amount (the "lisp-heap-gc-threshold") of free memory is available. The initial value of this kernel variable is 16MB on 32-bit implementations and 32MB on 64-bit implementations ; it can be manipulated from Lisp (see below.)

The large reserved memory block consumes very little in the way of system resources; memory that's actually committed to the lisp heap (live data and the "threshold" area where allocation takes place) consumes finite resources (physical memory and swap space). The lisp's consumption of those resources is proportional to its actual memory usage, which is generally a good thing.

This scheme is much more flexible than the old one, but it may also increase the possibility that those resources can become exhausted. Neither the new scheme nor the old handles that situation gracefully; under the old scheme, a program that consumes lots of memory may have run into an artificial limit on heap size before exhausting virtual memory.

The -R or –heap-reserve command-line option can be use to limit the size of the reserved block and therefore bound heap expansion. Running

> openmcl --heap-reserve 8M

would provide an execution environment that's very similar to that provided by earlier CCL versions.

Previous Chapter Next Section Table of Contents Glossary Index