Build fluency in the vocabulary of deferring memory reclamation until every thread has advanced past the removal epoch.
0 / 5 completed
1 / 5
A teammate explains that a lock-free data structure defers actually freeing a removed node until every thread that could still be holding a reference to it has advanced past the epoch in which the removal happened, tracked via per-thread epoch counters. What memory-reclamation technique is being described?
Epoch-based reclamation is exactly this: each thread periodically announces the current global epoch it has observed, and a removed node is only actually freed once every thread's announced epoch has advanced past the epoch in which the removal happened, guaranteeing no thread could still hold a reference to that node from an older epoch. A DNS zone transfer is an unrelated concept about replicating name server records. This defer-free-until-all-threads-advance approach is exactly why epoch-based reclamation is used to safely free memory in lock-free data structures without pausing readers.
2 / 5
During a design review, the team relies on epoch-based reclamation for a lock-free hash map accessed by dozens of concurrent reader threads, specifically so a removed node's memory is only freed once it is provably safe, without ever pausing the readers to check. Which capability does this provide?
Epoch-based reclamation here provides safe memory reclamation without pausing concurrent readers, since a node is only freed once every reader's tracked epoch proves it can no longer hold a reference to that node. Freeing a removed node immediately the moment it is unlinked, regardless of whether any reader might still hold a reference, risks a reader dereferencing freed memory, a classic use-after-free bug in lock-free structures. This defer-until-provably-safe behavior is exactly why epoch-based reclamation is favored for lock-free data structures with many concurrent readers.
3 / 5
In a code review, a dev notices a lock-free hash map frees a node's memory immediately after unlinking it from the structure, with no mechanism tracking whether any concurrent reader thread might still hold a reference to that node. What does this represent?
This is a missed epoch-based-reclamation requirement, since freeing immediately with no tracking risks a concurrent reader dereferencing memory that has already been freed. A cache eviction policy is an unrelated concept about discarded cache entries. This immediate-free-with-no-tracking pattern is exactly the kind of use-after-free hazard a reviewer flags once a data structure is accessed lock-free by concurrent readers.
4 / 5
An incident report shows a service crashed with memory corruption because a lock-free hash map freed a removed node immediately, while a concurrent reader thread was still mid-traversal and dereferenced the now-freed memory. What practice would prevent this?
Adopting epoch-based reclamation ensures a removed node is only freed once every reader's tracked epoch proves it can no longer hold a reference, preventing the use-after-free. Continuing to free removed nodes immediately with no epoch tracking regardless of how many concurrent readers might still be mid-traversal is exactly what caused the corruption described in this incident. This defer-until-provably-safe approach is the standard fix once immediate frees are confirmed to race with concurrent readers.
5 / 5
During a PR review, a teammate asks why the team reaches for epoch-based reclamation instead of simply wrapping every access to the lock-free structure in a global lock, given that a global lock trivially prevents any use-after-free. What is the reasoning?
Epoch-based reclamation trades some bookkeeping overhead tracking per-thread epochs for readers that never block at all, while a global lock trivially prevents use-after-free but serializes every access, defeating the purpose of a lock-free structure. This is exactly why epoch-based reclamation is favored for genuinely lock-free data structures with many concurrent readers, while a global lock remains acceptable only when the structure does not need to be lock-free in the first place.