Commit 9f3170da authored by Rodrigo Bruno's avatar Rodrigo Bruno Committed by Commit Bot

[heap] Add external memory counter to HeapStatistics.

Node.js is using AdjustAmountOfExternalAllocatedMemory to get
external memory from V8 [1]. In addition, they have a unittest
that verifies that AdjustAmountOfExternalAllocatedMemory returns
the correct value [2]. This CL proposes a new way to report
external memory through HeapStatistics.

[1]https://github.com/nodejs/node/blob/07cb69720bec251a1c450b3770db2136ac009778/src/node_process.cc#L187
[2]https://github.com/nodejs/node/blob/master/test/parallel/test-memory-usage.js

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ia58ed0bab1c1d4ee23672e1347b9a00b6705a43c
Reviewed-on: https://chromium-review.googlesource.com/1162156
Commit-Queue: Rodrigo Bruno <rfbpb@google.com>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54919}
parent d084929d
......@@ -6684,6 +6684,7 @@ class V8_EXPORT HeapStatistics {
size_t used_heap_size() { return used_heap_size_; }
size_t heap_size_limit() { return heap_size_limit_; }
size_t malloced_memory() { return malloced_memory_; }
size_t external_memory() { return external_memory_; }
size_t peak_malloced_memory() { return peak_malloced_memory_; }
size_t number_of_native_contexts() { return number_of_native_contexts_; }
size_t number_of_detached_contexts() { return number_of_detached_contexts_; }
......@@ -6702,6 +6703,7 @@ class V8_EXPORT HeapStatistics {
size_t used_heap_size_;
size_t heap_size_limit_;
size_t malloced_memory_;
size_t external_memory_;
size_t peak_malloced_memory_;
bool does_zap_garbage_;
size_t number_of_native_contexts_;
......
......@@ -5946,6 +5946,7 @@ HeapStatistics::HeapStatistics()
used_heap_size_(0),
heap_size_limit_(0),
malloced_memory_(0),
external_memory_(0),
peak_malloced_memory_(0),
does_zap_garbage_(0),
number_of_native_contexts_(0),
......@@ -8374,6 +8375,7 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
heap_statistics->malloced_memory_ =
isolate->allocator()->GetCurrentMemoryUsage() +
isolate->wasm_engine()->allocator()->GetCurrentMemoryUsage();
heap_statistics->external_memory_ = isolate->heap()->external_memory();
heap_statistics->peak_malloced_memory_ =
isolate->allocator()->GetMaxMemoryUsage() +
isolate->wasm_engine()->allocator()->GetMaxMemoryUsage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment