javascript - understanding V8's heap information in nodejs - Stack Overflow

from the docs, v8.getHeapSpaceStatistics() returns something like this, [{"space_name": "

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?

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?

Share Improve this question edited Jan 3, 2020 at 12:04 T.J. Crowder 1.1m200 gold badges2k silver badges2k bronze badges asked Jan 3, 2020 at 12:02 laxmanlaxman 2,1204 gold badges18 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

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./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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745310180a4621957.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信