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.
In more detail
New objects start in the small new space, which is cleaned often and quickly. Objects that survive a couple of collections move to old space, compiled code goes to code space, and very large objects get large object space. v8.getHeapSpaceStatistics() reports the size of each.
Related terms
- heap — The area of memory where a program stores objects whose size or lifetime is not known in advance, typically reclaimed by a garbage collector.
- 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.
- 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.
Taught in
- Node.js Process Architecture: Memory & Heap Spaces — Node.js Internals & Backend Services
- Runtime Configuration: CLI Flags & Native --env-file — Node.js Internals & Backend Services
- Diagnostic Profiling: CPU Profiler & Heap Snapshots — Node.js Internals & Backend Services