5 Storage Management in Common Lisp
5.1 About storage in Lisp Liquid Common Lisp manages storage allocation by providing a dynamic area in memory in which Lisp objects can be created. When Lisp objects are created, Lisp automatically allocates memory space for them. When objects are no longer used, a garbage-collecting program reclaims the storage space so that new objects can be created. Lisp programs can thus create objects without explicitly allocating and deallocating memory for them.
Liquid Common Lisp has two garbage collection programs, which are both enabled by default. The Dynamic Garbage Collector is a stop-and-copy compacting garbage collector that reclaims storage in space that is divided into two large dynamic areas. The Ephemeral Garbage Collector is a lifetime-based garbage collector that reclaims storage allocated in small storage areas that supplement the dynamic areas. Ephemeral garbage collection is normally faster than dynamic garbage collection and can reduce or eliminate the number of dynamic garbage collections.
In addition to the garbage-collecting programs that reclaim space, Lisp has a storage allocator that expands memory as required. You can control memory expansion by changing the parameters of the storage allocator.
Storage is normally used as follows:
During development, you can usually proceed without altering the normal garbage collection and storage allocation procedures. If an application requires more memory or a different storage layout, however, you can do the following:
- New Lisp objects are created in the normal consing area, which is the ephemeral space if the Ephemeral Garbage Collector is on and the dynamic space if the Ephemeral Garbage Collector is off.
- When either the ephemeral space or the dynamic space is full, computation pauses while the appropriate garbage collector is called to reclaim storage. If the garbage collection reclaims enough storage, the creation of Lisp objects continues in the normal consing area.
- If a garbage collection cannot reclaim enough storage to continue creating objects, Lisp attempts to expand dynamic memory. If storage is exhausted and Lisp cannot expand memory, it disables all garbage collection. You can then choose whether to proceed without garbage collection. If storage is again exhausted, the Lisp process halts irrevocably.
- If an application has unusual consing requirements, you can explicitly disable or enable the garbage collectors. See Section 126.96.36.199 on page 83 and Section 188.8.131.52 on page 84 for more information.
- If ephemeral garbage collection is occurring too often, you can modify the size and number of levels in the ephemeral space. See Section 184.108.40.206 on page 85 for more information.
- If an application requires more memory, you can explicitly expand memory or modify the parameters controlling automatic memory expansion. Because ephemeral garbage collection normally reduces the amount of dynamic space needed for an application, you should reevaluate the memory use of applications that did not previously use ephemeral garbage collection. See Section 5.4 on page 86 for more information.
The User's Guide - 9 SEP 1996
Generated with Harlequin WebMaker