Contents    Page-10    Prev    Next    Page+10    Index   

Reference Counting

Another method of managing Lisp storage involves reference counting. Conceptually, within each cons cell there is room for a small counter that counts the number of pointers which point to that cell. Each time another pointer to the cell is constructed, the counter is incremented by one. Each time a pointer is moved away from the cell, the counter is decremented by one.

Whenever the reference count of a cell becomes zero, the cell is garbage and may be added to the Free List. In addition, the reference counts of whatever its pointers point to must also be decremented, possibly resulting in additional garbage.