v8.getHeapStatistics()


返回拥有以下参数的对象:

does_zap_garbage是个0/1式布尔值,它凸显是否设置了--zap_code_space选项。若为真,那么V8引擎会用一个位模式来覆盖堆中的垃圾。如此,RSS(常驻内存集)会变得越来越大,因为V8会一直征用所有的堆页,从而让他们更难被操作系统交换掉。

For example:

{
  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
}

Returns an object with the following properties:

does_zap_garbage is a 0/1 boolean, which signifies whether the --zap_code_space option is enabled or not. This makes V8 overwrite heap garbage with a bit pattern. The RSS footprint (resident memory set) gets bigger because it continuously touches all heap pages and that makes them less likely to get swapped out by the operating system.

{
  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
}