A garbage collector can trace reachable objects without stopping application execution. Concurrent marking moves tracing to background threads while JavaScript continues on the main thread, reducing direct pause time but requiring synchronization when application code mutates the object graph. section 9.2.3
The marker classifies objects as white, grey, or black: white objects are unvisited, grey objects are discovered but not fully scanned, and black objects have had their outgoing references processed. Application writes can invalidate that progress, so write barriers record or otherwise expose mutations for the collector. V8 combines concurrent marking with incremental marking, leaving background threads to handle most work while the main thread handles necessary slices. section 9.2.3
Figure 9.5 Tri-color marking in V8's old generation. Objects start white (unvisited). When the collector discovers an object, it marks it grey (found but not yet scanned). After following all outgoing references, it marks the object black (fully processed). Any object still white when marking completes is unreachable and can be reclaimed.
Use the tri-color diagram to follow the marker’s advancing frontier and understand why white objects remaining at completion are reclaimable. section 9.2.3
When concurrent marking falls behind
JSC’s concurrent marker can enter a death spiral when a long-lived cache or session store is repeatedly updated with newly allocated objects. Each write may force the collector to revisit an object, allowing application mutations to generate work faster than the marker can process it. JSC’s space-time scheduler responds by granting the collector progressively more CPU time as allocation consumes its headroom; if the budget is exhausted, it pauses the application so marking can finish. section 9.3.4
Practical distinctions:
- Concurrent marking shifts tracing away from the main thread; incremental marking instead interleaves short tracing slices with application execution. section 9.2.3
- Concurrent execution reduces visible pauses but does not eliminate coordination costs or latency under heavy mutation and allocation. section 9.2.3 section 9.3.4
