Tombstone (programming)
This article needs additional citations for verification. (April 2007) |
Tombstones are a solution to dangling pointers that can appear in certain computer programming languages, e. g. C, C++ and assembly 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. However, built-in support by the programming language or the compiler is not necessary to use them.