Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are v8 old space and new space?

Tags:

v8

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?

like image 543
exebook Avatar asked Nov 27 '14 16:11

exebook


People also ask

What is V8 heap memory?

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.

Does V8 have garbage collection?

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.

How does Javascript garbage collection work?

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.


1 Answers

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

like image 99
fuentesjr Avatar answered Oct 23 '22 18:10

fuentesjr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!