Build fluency in the vocabulary of tracking objects as white, gray, or black to safely collect garbage concurrently with the application.
0 / 5 completed
1 / 5
A teammate explains that a concurrent garbage collector tracks each object as white, meaning unvisited, gray, meaning visited but its references not yet scanned, or black, meaning fully scanned, to safely reclaim memory while the application keeps running and mutating references. What algorithm is being described?
Tri-color marking is exactly this: every object is classified as white if unvisited, gray if visited but its outgoing references have not yet been scanned, or black if fully scanned along with all its references, and this invariant lets a concurrent collector safely reclaim only white objects at the end of a pass, even while the application mutates references during collection, as long as a write barrier prevents a black object from ever pointing directly to a white one. A DNS zone transfer is an unrelated concept about replicating name server records. This white-gray-black-invariant approach is exactly why tri-color marking underlies concurrent and incremental garbage collectors.
2 / 5
During a design review, the team relies on tri-color marking with a write barrier for a low-latency service that cannot tolerate long stop-the-world pauses, specifically so collection can proceed concurrently with the application mutating object references. Which capability does this provide?
Tri-color marking with a write barrier here provides safe concurrent collection despite the application mutating references mid-pass, since the write barrier prevents a black object from ever pointing directly to an unmarked white object, which would otherwise let a live object be mistakenly reclaimed. A stop-the-world collector that halts the application for the entire marking phase avoids that hazard by simply not letting the application run concurrently at all, at the cost of a longer pause. This safe-concurrent-mutation behavior is exactly why tri-color marking is favored for low-latency services.
3 / 5
In a code review, a dev notices a garbage collector marks objects reachable from the roots but has no write barrier to catch a black object later being mutated to point at a white object, while the application keeps running concurrently during marking. What does this represent?
This is a missed tri-color-marking safety requirement, since without a write barrier a black object can end up pointing at a white object that gets wrongly reclaimed. A cache eviction policy is an unrelated concept about discarded cache entries. This missing-write-barrier gap is exactly the kind of correctness hazard a reviewer flags once marking must remain safe while the application runs concurrently.
4 / 5
An incident report shows a service crashed with a use-after-free-style corruption because a concurrent collector reclaimed an object that a black object still referenced, since no write barrier caught the black-to-white reference created after that object was marked. What practice would prevent this?
Adding a proper write barrier to the tri-color-marking implementation ensures a mutation creating a black-to-white reference is caught and the white object is kept alive instead of being wrongly reclaimed. Continuing to run concurrent marking without any write barrier regardless of how many black-to-white references get created during mutation is exactly what caused the corruption described in this incident. This write-barrier-enforced-invariant approach is the standard fix once concurrent marking is confirmed to need it for safety.
5 / 5
During a PR review, a teammate asks why the team reaches for tri-color marking with a write barrier instead of a simple stop-the-world mark phase that halts the application entirely while scanning, given that stopping the world avoids any write-barrier complexity. What is the reasoning?
Tri-color marking trades write-barrier bookkeeping overhead on every reference mutation for the ability to collect concurrently without a long application pause, while stop-the-world marking is simpler but freezes the application for the full scan. This is exactly why tri-color marking is favored in low-latency, garbage-collected runtimes, while stop-the-world marking remains acceptable when brief full-application pauses are tolerable.