最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论