理解V8在nodejs中的堆信息
understanding V8's heap information in nodejs
来自文档,v8.getHeapSpaceStatistics() returns 类似这样的东西,
[
{
"space_name": "new_space",
"space_size": 2063872,
"space_used_size": 951112,
"space_available_size": 80824,
"physical_space_size": 2063872
},
...
]
还有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
}
有人可以解释一下这些键和空格的实际含义吗?
V8 管理不同空间的堆,new_space
用于快速垃圾收集的新对象,而 old_space
用于寿命更长的对象。 v8.getHeapSpaceStatistics()
returns 不同空间的统计。
这篇文章对不同空格有更详细的解释:http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection
这里引用文章中的解释:
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.
v8.getHeapStatistics()
中各个字段的含义已经在这里得到解答:
来自文档,v8.getHeapSpaceStatistics() returns 类似这样的东西,
[
{
"space_name": "new_space",
"space_size": 2063872,
"space_used_size": 951112,
"space_available_size": 80824,
"physical_space_size": 2063872
},
...
]
还有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
}
有人可以解释一下这些键和空格的实际含义吗?
V8 管理不同空间的堆,new_space
用于快速垃圾收集的新对象,而 old_space
用于寿命更长的对象。 v8.getHeapSpaceStatistics()
returns 不同空间的统计。
这篇文章对不同空格有更详细的解释:http://jayconrod.com/posts/55/a-tour-of-v8-garbage-collection
这里引用文章中的解释:
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.
v8.getHeapStatistics()
中各个字段的含义已经在这里得到解答: