Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 399b340

Browse filesBrowse files
caiolimaaduh95
authored andcommitted
v8: adding total_allocated_bytes to HeapStatistics
PR-URL: #60573 Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent dc38a45 commit 399b340
Copy full SHA for 399b340

File tree

Expand file treeCollapse file tree

6 files changed

+13
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+13
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/v8.md‎

Copy file name to clipboardExpand all lines: doc/api/v8.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Returns an object with the following properties:
197197
* `total_global_handles_size` {number}
198198
* `used_global_handles_size` {number}
199199
* `external_memory` {number}
200+
* `total_allocated_bytes` {number}
200201

201202
`total_heap_size` The value of total\_heap\_size is the number of bytes V8 has
202203
allocated for the heap. This can grow if used\_heap needs more memory.
@@ -250,6 +251,9 @@ used memory size of V8 global handles.
250251
`external_memory` The value of external\_memory is the memory size of array
251252
buffers and external strings.
252253

254+
`total_allocated_bytes` The value of total allocated bytes since the Isolate
255+
creation
256+
253257
<!-- eslint-skip -->
254258

255259
```js
Collapse file

‎lib/v8.js‎

Copy file name to clipboardExpand all lines: lib/v8.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const {
136136
kTotalGlobalHandlesSizeIndex,
137137
kUsedGlobalHandlesSizeIndex,
138138
kExternalMemoryIndex,
139+
kTotalAllocatedBytes,
139140

140141
// Properties for heap spaces statistics buffer extraction.
141142
kHeapSpaces,
@@ -246,6 +247,7 @@ function getHeapStatistics() {
246247
total_global_handles_size: buffer[kTotalGlobalHandlesSizeIndex],
247248
used_global_handles_size: buffer[kUsedGlobalHandlesSizeIndex],
248249
external_memory: buffer[kExternalMemoryIndex],
250+
total_allocated_bytes: buffer[kTotalAllocatedBytes],
249251
};
250252
}
251253

Collapse file

‎src/node_v8.cc‎

Copy file name to clipboardExpand all lines: src/node_v8.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ using v8::Value;
7373
V(10, number_of_detached_contexts, kNumberOfDetachedContextsIndex) \
7474
V(11, total_global_handles_size, kTotalGlobalHandlesSizeIndex) \
7575
V(12, used_global_handles_size, kUsedGlobalHandlesSizeIndex) \
76-
V(13, external_memory, kExternalMemoryIndex)
76+
V(13, external_memory, kExternalMemoryIndex) \
77+
V(14, total_allocated_bytes, kTotalAllocatedBytes)
7778

7879
#define V(a, b, c) +1
7980
static constexpr size_t kHeapStatisticsPropertiesCount =
Collapse file

‎src/node_worker.cc‎

Copy file name to clipboardExpand all lines: src/node_worker.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ void Worker::GetHeapStatistics(const FunctionCallbackInfo<Value>& args) {
12631263
"total_global_handles_size",
12641264
"used_global_handles_size",
12651265
"external_memory",
1266+
"total_allocated_bytes",
12661267
};
12671268
tmpl = DictionaryTemplate::New(isolate, heap_stats_names);
12681269
env->set_heap_statistics_template(tmpl);
@@ -1283,7 +1284,8 @@ void Worker::GetHeapStatistics(const FunctionCallbackInfo<Value>& args) {
12831284
Number::New(isolate, heap_stats->number_of_detached_contexts()),
12841285
Number::New(isolate, heap_stats->total_global_handles_size()),
12851286
Number::New(isolate, heap_stats->used_global_handles_size()),
1286-
Number::New(isolate, heap_stats->external_memory())};
1287+
Number::New(isolate, heap_stats->external_memory()),
1288+
Number::New(isolate, heap_stats->total_allocated_bytes())};
12871289

12881290
Local<Object> obj;
12891291
if (!NewDictionaryInstanceNullProto(
Collapse file

‎test/parallel/test-v8-stats.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-v8-stats.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const keys = [
1212
'number_of_detached_contexts',
1313
'number_of_native_contexts',
1414
'peak_malloced_memory',
15+
'total_allocated_bytes',
1516
'total_available_size',
1617
'total_global_handles_size',
1718
'total_heap_size',
Collapse file

‎test/parallel/test-worker-heap-statistics.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-worker-heap-statistics.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ if (isMainThread) {
4040
`total_global_handles_size`,
4141
`used_global_handles_size`,
4242
`external_memory`,
43+
`total_allocated_bytes`,
4344
].sort();
4445
assert.deepStrictEqual(keys, Object.keys(stats).sort());
4546
for (const key of keys) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.