Tombstone (programming)
From Wikipedia, the free encyclopedia
This article or section is missing citations or needs footnotes. Using inline citations helps guard against copyright violations and factual inaccuracies. (April 2007) |
Tombstones are 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 popular programming language currently uses tombstones.