Node.js · Senior · Question 1 of 75
How is the V8 heap organized for garbage collection?
- 1Into one region per JavaScript module
- ✓Correct answer: Into a young generation (new objects, collected often by a fast scavenger) and an old generation (long-lived objects, collected by mark-sweep-compact)
- 3Into one flat area that is scanned in full on every allocation
Explanation
Most objects die young, so frequent cheap scavenges reclaim them. Objects that survive are promoted to the old generation, whose collections are rarer and more expensive, though mostly concurrent and incremental.