Facebook Pixel

What is the difference between minor and major GC in V8?

Minor GC (scavenge) collects the young generation, which is fast and frequent. Major GC (mark-sweep or mark-compact) collects the old generation, which is slower and less frequent. The split makes garbage collection efficient.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Garbage Collection in V8 and Node.js Explained

V8 uses a generational garbage collector. New objects are in the young generation, collected often (minor GC). Long-lived objects move to the old generation, collected less often (major GC). The GC finds unreachable objects and frees their memory automatically.

When objects are still referenced unintentionally. A forgotten event listener keeping an object alive, a closure capturing more than it needs, or a global cache growing without bounds. These prevent GC from freeing memory, since the objects are still reachable.

Use the Node.js inspector and heap snapshots. Take a snapshot, run your code, take another, and compare. Growing objects between snapshots point to the leak. This is the standard way to find leaks in production Node.js apps.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0