Chapter 7. Memory Management

7.1. Implementation Types
7.2. Heap and Relocatable Areas
7.3. The Garbage Collector
7.4. Allocation Functions
7.5. Storage Information

The following sections only apply to the ECL original garbage collector. If ECL is not compiled with --disable-boehm, then an alternative, less restrictive garbage collector is installed, with the disadvantage that many of the following functions #'room, si:*gc-verbose*, … do no longer work.

7.1. Implementation Types

Each ECL object belongs to one of the 22 implementation types. The implementation types are shown in Table 4-1 with the corresponding Common-Lisp data types. In the table, the compiled functions are divided into three implementation types; cfun is the type of compiled functions without environment, cclosure is the type of compiled functions with environment (i.e., the type of compiled closures) and gfun is the type of compiled generic functions of CLOS.

Table 4-1 Implementation Types

Implementation TypeCommon-Lisp Data Type
conscons
fixnumfixnum
bignumbignum
ratioratio
short-floatshort-float
long-floatlong-float (= double-float = single-float)
complexcomplex
charactercharacter
symbolsymbol
packagepackage
hash-tablehash-table
array(and array (not vector))
vector(and vector (not string) (not bit-vector))
stringstring
bit-vectorbit-vector
structurestructure
streamstream
random-staterandom-state
readtablereadtable
cfuncompiled-function without environment
cclosurecompiled-function with environment
gfunnone (CLOS generic-function)
instancenone (CLOS instance)
threadnone (thread)
  

Each object is represented by a cell allocated in the heap area of the interpreter. The size of the cell is determined by the implementation type of the object.

The implementation types are classified according to the size of the cells for the objects of the type, as shown in Table 4-2. The size of the cells in the same type class is the same.

Table 4-2 Classification of Implementation Types

1CONS BIGNUM RATIO COMPLEX STRUCTURE
2SHORT-FLOAT RANDOM-STATE READTABLE
3LONG-FLOAT CFUN CCLOSURE
4SYMBOL
5PACKAGE
6ARRAY HASH-TABLE VECTOR BIT-VECTOR STREAM
7STRING
8PATHNAME

For objects of the (implementation) types readtable, symbol, package, array, hash-table, vector, bit-vector, stream, cclosure, string, cfun, and structure (or instance), the cell is simply a header of the object. The body of the object is allocated separately from the cell and is managed in a different manner. The memory space occupied by the body of such an object is called a block. A block is either contiguous or relocatable depending on the area in which it is allocated. The difference between the two areas will be explained below. Table 4-3 lists these types, along with the contents of the body and the kind of the block.

Table 4-3 Types with Bodies

readtableread tablecontiguous
symbolsymbol namerelocatable
packagehash tablecontiguous
arrayarray bodyrelocatable or contiguous
hash-tablehash tablerelocatable
vectorvector bodyrelocatable or contiguous
bit-vectorbit-vector bodyrelocatable or contiguous
streamI/O buffercontiguous
cclosurecodecontiguous
stringstring bodyrelocatable or contiguous
cfuncodecontiguous
structurestructure bodyrelocatable
instanceinstance slotsrelocatable
threadthread datacontiguous

Usually, the body of an array, a vector, a bit-vector, or a string is allocated as a relocatable block. In ECL, the function make-array takes an extra keyword argument :static. If the :static argument is supplied with a non-() value, then the body of the array is allocated as a contiguous block.