Reputation: 2110
from the docs, v8.getHeapSpaceStatistics() returns something like this,
[
{
"space_name": "new_space",
"space_size": 2063872,
"space_used_size": 951112,
"space_available_size": 80824,
"physical_space_size": 2063872
},
...
]
Also v8.getHeapStatistics(), returns
{
total_heap_size: 7326976,
total_heap_size_executable: 4194304,
total_physical_size: 7326976,
total_available_size: 1152656,
used_heap_size: 3476208,
heap_size_limit: 1535115264,
malloced_memory: 16384,
peak_malloced_memory: 1127496,
does_zap_garbage: 0,
number_of_native_contexts: 1,
number_of_detached_contexts: 0
}
Can somebody please explain what these keys and spaces actually mean?
Upvotes: 3
Views: 1964
Reputation: 6903
V8 manages heap in different spaces, new_space
is used for new objects which are quickly garbaged collected, while old_space
is for longer lived objects. v8.getHeapSpaceStatistics()
returns statistics about the different spaces.
This article has a more detailed explanation of the different spaces: http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection
Here is a quote of the explanation in the article:
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-pointer-space: Contains most objects which may have pointers to other objects. Most objects are moved here after surviving in new-space for a while.
Old-data-space: Contains objects which just contain raw data (no pointers to other objects). Strings, boxed numbers, and arrays of unboxed doubles are moved here after surviving in new-space for a while.
Large-object-space: This space contains objects which are larger than the size limits of other spaces. Each object gets its own mmap'd region of memory. Large objects are never moved by the garbage collector.
Code-space: Code objects, which contain JITed instructions, are allocated here. This is the only space with executable memory (although Codes may be allocated in large-object-space, and those are executable, too).
Cell-space, property-cell-space and map-space: These spaces contain Cells, PropertyCells, and Maps, respectively. Each of these spaces contains objects which are all the same size and has some constraints on what kind of objects they point to, which simplifies collection.
The meaning of the different fields in v8.getHeapStatistics()
has already been answered here:
nodejs v8.getHeapStatistics method
Upvotes: 9