src: export number_of_native_contexts and number_of_detached_contexts

export number_of_native_contexts and number_of_detached_contexts as
part of v8.getHeapStatistics()

PR-URL: https://github.com/nodejs/node/pull/27933
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Yuriy Vasiyarov authored and Michaël Zasso committed 2019-05-31 08:46:56 +02:00
1 parent 5eccd642ef
commit 33236b7c54
4 files changed
+25 -4

No files matched your search

+14 -1
View File
@@ -131,6 +131,9 @@ Returns an object with the following properties:
* `malloced_memory` {number}
* `peak_malloced_memory` {number}
* `does_zap_garbage` {number}
* `number_of_native_contexts` {number}
* `number_of_detached_contexts` {number}
`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
@@ -138,6 +141,14 @@ 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.
`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` 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.
<!-- eslint-skip -->
```js
{
@@ -149,7 +160,9 @@ to get swapped out by the operating system.
heap_size_limit: 1535115264,
malloced_memory: 16384,
peak_malloced_memory: 1127496,
does_zap_garbage: 0
does_zap_garbage: 0,
number_of_native_contexts: 1,
number_of_detached_contexts: 0
}
```
+6 -2
View File
@@ -109,7 +109,9 @@ const {
kSpaceSizeIndex,
kSpaceUsedSizeIndex,
kSpaceAvailableSizeIndex,
kPhysicalSpaceSizeIndex
kPhysicalSpaceSizeIndex,
kNumberOfNativeContextsIndex,
kNumberOfDetachedContextsIndex
} = internalBinding('v8');
const kNumberOfHeapSpaces = kHeapSpaces.length;
@@ -139,7 +141,9 @@ function getHeapStatistics() {
'heap_size_limit': buffer[kHeapSizeLimitIndex],
'malloced_memory': buffer[kMallocedMemoryIndex],
'peak_malloced_memory': buffer[kPeakMallocedMemoryIndex],
'does_zap_garbage': buffer[kDoesZapGarbageIndex]
'does_zap_garbage': buffer[kDoesZapGarbageIndex],
'number_of_native_contexts': buffer[kNumberOfNativeContextsIndex],
'number_of_detached_contexts': buffer[kNumberOfDetachedContextsIndex]
};
}
+3 -1
View File
@@ -52,7 +52,9 @@ using v8::Value;
V(5, heap_size_limit, kHeapSizeLimitIndex) \
V(6, malloced_memory, kMallocedMemoryIndex) \
V(7, peak_malloced_memory, kPeakMallocedMemoryIndex) \
V(8, does_zap_garbage, kDoesZapGarbageIndex)
V(8, does_zap_garbage, kDoesZapGarbageIndex) \
V(9, number_of_native_contexts, kNumberOfNativeContextsIndex) \
V(10, number_of_detached_contexts, kNumberOfDetachedContextsIndex)
#define V(a, b, c) +1
static const size_t kHeapStatisticsPropertiesCount =
+2
View File
@@ -8,6 +8,8 @@ const keys = [
'does_zap_garbage',
'heap_size_limit',
'malloced_memory',
'number_of_detached_contexts',
'number_of_native_contexts',
'peak_malloced_memory',
'total_available_size',
'total_heap_size',