v8: export more fields in getHeapStatistics · nodejs/node@a19fb60 · GitHub
Skip to content

Commit a19fb60

Browse files
theanarkhtargos
authored andcommitted
v8: export more fields in getHeapStatistics
export total_global_handles_size, used_global_handles_size, external_memory in getHeapStatistics PR-URL: #42784 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b0f7c4c commit a19fb60

4 files changed

Lines changed: 41 additions & 15 deletions

File tree

doc/api/v8.md

Lines changed: 16 additions & 1 deletion

lib/v8.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ const {
107107
kPeakMallocedMemoryIndex,
108108
kNumberOfNativeContextsIndex,
109109
kNumberOfDetachedContextsIndex,
110+
kTotalGlobalHandlesSizeIndex,
111+
kUsedGlobalHandlesSizeIndex,
112+
kExternalMemoryIndex,
110113

111114
// Properties for heap spaces statistics buffer extraction.
112115
kHeapSpaces,
@@ -165,7 +168,10 @@ function getHeapStatistics() {
165168
peak_malloced_memory: buffer[kPeakMallocedMemoryIndex],
166169
does_zap_garbage: buffer[kDoesZapGarbageIndex],
167170
number_of_native_contexts: buffer[kNumberOfNativeContextsIndex],
168-
number_of_detached_contexts: buffer[kNumberOfDetachedContextsIndex]
171+
number_of_detached_contexts: buffer[kNumberOfDetachedContextsIndex],
172+
total_global_handles_size: buffer[kTotalGlobalHandlesSizeIndex],
173+
used_global_handles_size: buffer[kUsedGlobalHandlesSizeIndex],
174+
external_memory: buffer[kExternalMemoryIndex]
169175
};
170176
}
171177

src/node_v8.cc

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,21 @@ using v8::Uint32;
4747
using v8::V8;
4848
using v8::Value;
4949

50-
51-
#define HEAP_STATISTICS_PROPERTIES(V) \
52-
V(0, total_heap_size, kTotalHeapSizeIndex) \
53-
V(1, total_heap_size_executable, kTotalHeapSizeExecutableIndex) \
54-
V(2, total_physical_size, kTotalPhysicalSizeIndex) \
55-
V(3, total_available_size, kTotalAvailableSize) \
56-
V(4, used_heap_size, kUsedHeapSizeIndex) \
57-
V(5, heap_size_limit, kHeapSizeLimitIndex) \
58-
V(6, malloced_memory, kMallocedMemoryIndex) \
59-
V(7, peak_malloced_memory, kPeakMallocedMemoryIndex) \
60-
V(8, does_zap_garbage, kDoesZapGarbageIndex) \
61-
V(9, number_of_native_contexts, kNumberOfNativeContextsIndex) \
62-
V(10, number_of_detached_contexts, kNumberOfDetachedContextsIndex)
50+
#define HEAP_STATISTICS_PROPERTIES(V) \
51+
V(0, total_heap_size, kTotalHeapSizeIndex) \
52+
V(1, total_heap_size_executable, kTotalHeapSizeExecutableIndex) \
53+
V(2, total_physical_size, kTotalPhysicalSizeIndex) \
54+
V(3, total_available_size, kTotalAvailableSize) \
55+
V(4, used_heap_size, kUsedHeapSizeIndex) \
56+
V(5, heap_size_limit, kHeapSizeLimitIndex) \
57+
V(6, malloced_memory, kMallocedMemoryIndex) \
58+
V(7, peak_malloced_memory, kPeakMallocedMemoryIndex) \
59+
V(8, does_zap_garbage, kDoesZapGarbageIndex) \
60+
V(9, number_of_native_contexts, kNumberOfNativeContextsIndex) \
61+
V(10, number_of_detached_contexts, kNumberOfDetachedContextsIndex) \
62+
V(11, total_global_handles_size, kTotalGlobalHandlesSizeIndex) \
63+
V(12, used_global_handles_size, kUsedGlobalHandlesSizeIndex) \
64+
V(13, external_memory, kExternalMemoryIndex)
6365

6466
#define V(a, b, c) +1
6567
static constexpr size_t kHeapStatisticsPropertiesCount =

test/parallel/test-v8-stats.js

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)