Hazard pointers¶
Category: Lock-free · Status: stub
One line: Each thread publishes the pointers it is about to use, and memory is freed only when no thread has it published — safe memory reclamation for lock-free data structures.
Also called: safe memory reclamation.
How it connects¶
flowchart LR
n_aba_problem["ABA problem"]
n_hazard_pointers["Hazard pointers"]
n_hazard_pointers -->|prevents| n_aba_problem
classDef center stroke-width:3px
class n_hazard_pointers center
classDef outside stroke-dasharray: 4 3
class n_aba_problem outside
- Helps prevent: ABA problem
- See also: Concurrent data structures, Lock-free, Read-copy-update
In each language¶
| C++ | <hazard_pointer> ↗ (C++26): hazard_pointer_obj_base, hazard_pointer and make_hazard_pointer |
Where to read more¶
- In the books: Hands-On Concurrency with Rust, Brian L. Troutwine — ch. 7, 'Atomics – Safely Reclaiming Memory'
- In the books: The Art of Multiprocessor Programming, Maurice Herlihy, Nir Shavit — ch. 10, 'Concurrent Queues and the ABA Problem' → 'Memory Reclamation and the ABA Problem'
- Reference: Wikipedia: Hazard pointer ↗