reference counting


reference counting

(programming)A garbage collection technique where eachmemory cell contains a count of the number of other cellswhich point to it. If this count reaches zero the cell isfreed and its pointers to other cells are followed todecrement their counts, and so on recursively.

This technique cannot cope with circular data structures.Cells in such structures refer (indirectly) to themselves andso will never have a zero reference count. This means theywould never be reclaimed, even when there are no referencesfrom outside the structure.