Aging Pointer

An AgingPointer is strictly not a pointer, but acts like one, with special properties that provide, in effect, zero-cost garbage collection if certain conditions are met. It is called an AgingPointer because it automatically becomes 'nil' when it becomes 'too old'. Like a real pointer,

Thus it can be used in a variety of linked-list structures.

In a typical implementation, the AgingPointer is a large (32-bit or 64-bit) integer. The items that it may reference are elements of a fixed-size array associated with the type of the pointer.

The above pointer properties are typically implemented like this:

Initially, the Age variable is set to the most negative large integer value, and the Next Pointer variable is set to one more. (Or, if unsigned integers are used, the initial values are 0 and 1.)

The hidden costs of this pattern are the extra work of nil-testing and de-referencing, and the following restrictions:

-- JimClark


In what situations would an AgingPointer be of use?


CategoryPointer CategoryStructuralPatterns CategoryConcurrency


EditText of this page (last edited July 27, 2008) or FindPage with title or text search