Mark-Sweep-Compact
V8's full garbage collection for old space: mark every object still reachable, sweep away the rest, then compact memory to close the gaps.
In more detail
It is slower than a scavenge, so V8 does much of the marking in background threads while your code keeps running. A heap that stays nearly full triggers it often, which shows up as latency spikes.
Related terms
- garbage collection — The automatic freeing of memory held by objects that the program can no longer reach.
- Scavenge — V8's fast garbage collection for new space, which copies the few surviving young objects elsewhere and frees everything else at once.
- heap space — One of the separate regions V8 divides its heap into, such as new space for young objects and old space for long-lived ones.
Taught in
- Node.js Process Architecture: Memory & Heap Spaces — Node.js Internals & Backend Services