v8.getHeapStatistics()


返回具有以下属性的对象:

¥Returns an object with the following properties:

total_heap_size total_heap_size 的值是 V8 为堆分配的字节数。如果 used_heap 需要更多内存,则它可能会增加。

¥total_heap_size The value of total_heap_size is the number of bytes V8 has allocated for the heap. This can grow if used_heap needs more memory.

total_heap_size_executable total_heap_size_executable 的值是可以包含可执行代码的堆部分,以字节为单位。这包括 JIT 编译代码使用的内存和任何必须保持​​可执行的内存。

¥total_heap_size_executable The value of total_heap_size_executable is the portion of the heap that can contain executable code, in bytes. This includes memory used by JIT-compiled code and any memory that must be kept executable.

total_physical_size total_physical_size 的值是 V8 堆使用的实际物理内存,以字节为单位。这是已提交(或正在使用)而不是保留的内存量。

¥total_physical_size The value of total_physical_size is the actual physical memory used by the V8 heap, in bytes. This is the amount of memory that is committed (or in use) rather than reserved.

total_available_size total_available_size 的值是 V8 堆可用的内存字节数。此值表示 V8 在超出堆限制之前可以使用多少内存。

¥total_available_size The value of total_available_size is the number of bytes of memory available to the V8 heap. This value represents how much more memory V8 can use before it exceeds the heap limit.

used_heap_size used_heap_size 的值是 V8 的 JavaScript 对象当前正在使用的字节数。这是实际使用的内存,不包括已分配但尚未使用的内存。

¥used_heap_size The value of used_heap_size is number of bytes currently being used by V8’s JavaScript objects. This is the actual memory in use and does not include memory that has been allocated but not yet used.

heap_size_limit heap_size_limit 的值是 V8 堆的最大大小,以字节为单位(可以是默认限制,由系统资源决定,也可以是传递给 --max_old_space_size 选项的值)。

¥heap_size_limit The value of heap_size_limit is the maximum size of the V8 heap, in bytes (either the default limit, determined by system resources, or the value passed to the --max_old_space_size option).

malloced_memory malloced_memory 的值是 V8 通过 malloc 分配的字节数。

¥malloced_memory The value of malloced_memory is the number of bytes allocated through malloc by V8.

peak_malloced_memory peak_malloced_memory 的值是 V8 在进程的生命周期内通过 malloc 分配的峰值字节数。

¥peak_malloced_memory The value of peak_malloced_memory is the peak number of bytes allocated through malloc by V8 during the lifetime of the process.

does_zap_garbage 是 0/​​1 布尔值,表示是否启用了 --zap_code_space 选项。这使得 V8 使用位模式覆盖堆垃圾。RSS 占用空间(常驻集大小)变得更大,因为它不断接触所有堆页面,这使得它们不太可能被操作系统换出。

¥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 set size) gets bigger because it continuously touches all heap pages and that makes them less likely to get swapped out by the operating system.

number_of_native_contexts native_context 的值是当前活动的顶层上下文的数量。随着时间的推移此数字的增加表示内存泄漏。

¥number_of_native_contexts The value of native_context is the number of the top-level contexts currently active. Increase of this number over time indicates a memory leak.

number_of_detached_contexts detached_context 的值是已分离但尚未进行垃圾收集的上下文的数量。此数字非零表示潜在的内存泄漏。

¥number_of_detached_contexts The value of detached_context is the number of contexts that were detached and not yet garbage collected. This number being non-zero indicates a potential memory leak.

total_global_handles_size Total_global_handles_size 的值是 V8 全局句柄的总内存大小。

¥total_global_handles_size The value of total_global_handles_size is the total memory size of V8 global handles.

used_global_handles_size used_global_handles_size 的值是 V8 全局句柄的已用内存大小。

¥used_global_handles_size The value of used_global_handles_size is the used memory size of V8 global handles.

external_memory external_memory 的值是数组缓冲区和外部字符串的内存大小。

¥external_memory The value of external_memory is the memory size of array buffers and external strings.

{
  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,
  total_global_handles_size: 8192,
  used_global_handles_size: 3296,
  external_memory: 318824
}