seniorNode.js

V8 Garbage Collection: Scavenge vs Mark-Sweep

Updated May 4, 2026

Short answer

V8 uses a generational GC: 'Scavenge' (Minor GC) for short-lived objects in New Space, and 'Mark-Sweep/Compact' (Major GC) for long-lived objects in Old Space.

Deep explanation

Most objects die in New Space. V8 uses the Cheney algorithm to copy survivors. If an object survives multiple Minor GCs, it's promoted to Old Space. Major GC marks reachable objects, sweeps dead ones, and compacts memory.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Node.js interview questions

View all →