Jump to content

Tombstone (programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by PhilipMW (talk | contribs) at 00:01, 17 October 2005 (First draft). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Tombstones is a solution to dangling pointers in computer programming languages.

A tombstone is a structure that acts as an intermediary between a pointer and the heap-dynamic data in memory. The pointer points only at tombstones and never to the memory that holds the actual value. When the data is deallocated, the tombstone is set to a null value, indicating that the variable no longer exists. This prevents a pointer from ever pointing or attempting to dereference a deallocated variable, as it allows such references to be detected as an error.

The downsides of using tombstones include an overhead in processing and memory: extra processing is necessary to follow the path from the pointer to data through the tombstone, and extra memory is necessary to retain tombstones for every pointer throughout the program.

No widely used programming language uses tombstones.

See also