Node.js
has two parameters to control memory allocations as I know of:
--max_new_space_size
and --max_old_space_size
What exactly are those mentioned NEW SPACE
and OLD SPACE
things?
In V8, the garbage collector is named Orinoco. It divides the heap memory space into 2 regions: young generation and old generation. This design is based on a generational hypothesis: In most cases, young objects are much more likely to die than old objects. And the young/old generation take different strategies.
There are two garbage collectors in V8. The Major GC (Mark-Compact) collects garbage from the whole heap. The Minor GC (Scavenger) collects garbage in the young generation.
The garbage collector takes roots and “marks” (remembers) them. Then it visits and “marks” all references from them. Then it visits marked objects and marks their references. All visited objects are remembered, so as not to visit the same object twice in the future.
In a generational garbage collector (which V8 uses), the heap is generally divided into two spaces. A young generation (new-space) and an old generation (old-space). Infant mortality or the generational hypothesis is the observation that, in most cases, young objects are much more likely to die than old objects.
New-space: Most objects are allocated here. New-space is small and is designed to be garbage collected very quickly, independent of other spaces.
Old-space: Contains most objects which may have pointers to other objects. Most objects are moved here after surviving in new-space for a while.
Ref: http://www.memorymanagement.org/glossary/g.html#term-generational-hypothesis
Ref: http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With