v8-memoryAnswer last reviewed July 2026

V8 runs two kinds of collections, the scavenge and the full mark-sweep-compact. What's the real difference, and if my latency is suffering, which one do I blame?

Strong candidates tie each collector's algorithm to its pauses, weigh copying cost against marking cost, and know what modern V8 actually runs concurrently

What an AI-prepared candidate might say

So the scavenge is the minor GC, it cleans up new space. New space is small and most of what's in there is already dead, so scavenges finish fast, around a millisecond I think, and they run all the time. Mark-sweep-compact is the major GC and it goes over the entire heap. It marks everything that's still reachable, sweeps the dead objects, and compacts memory to cut down fragmentation. That's the expensive one, and historically that's where the noticeable pause spikes came from. Newer V8 softens this with incremental and concurrent techniques, so a lot of the marking happens in the background and the stop-the-world part stays short. For latency you basically watch the major GC. Frequent scavenges are normal and cheap. Long or frequent major collections show up directly in your tail latency.

Senior
Locked

The two cost models behind copying and marking, what Orinoco actually moved off the main thread, and the write barriers that keep concurrent marking honest.

Unlock the depth
Staff
Locked

How to read gc performance entries and blame the right collector, what GC thrash near the heap limit looks like, and the heap-headroom tradeoff nobody sizes properly.

Unlock the depth
Follow-up chain
V8 runs two kinds of collections, the scavenge and the full mark-sweep-compact. What's the real difference, and if my latency is suffering, which one do I blame? | NodeBook