Skip to content

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

In each language

C++ <hazard_pointer> (C++26): hazard_pointer_obj_base, hazard_pointer and make_hazard_pointer

Where to read more