diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-01-28 17:25:10 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-01-31 03:34:03 +0300 |
commit | abe6a2e3d1c268f5bebbf05864f2588c6f4858b5 (patch) | |
tree | 14aa5333cc111f78169dc17d5740f82bba845c1c /src/node_process_methods.cc | |
parent | 9225939528590f652e6ee1ccf73e709b029d4ca5 (diff) |
process: report ArrayBuffer memory in `memoryUsage()`
Report memory allocations performed by the `ArrayBuffer::Allocator`.
PR-URL: https://github.com/nodejs/node/pull/31550
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_process_methods.cc')
-rw-r--r-- | src/node_process_methods.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 7b91f89e791..4d53749f098 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -200,10 +200,13 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) { HeapStatistics v8_heap_stats; isolate->GetHeapStatistics(&v8_heap_stats); + NodeArrayBufferAllocator* array_buffer_allocator = + env->isolate_data()->node_allocator(); + // Get the double array pointer from the Float64Array argument. CHECK(args[0]->IsFloat64Array()); Local<Float64Array> array = args[0].As<Float64Array>(); - CHECK_EQ(array->Length(), 4); + CHECK_EQ(array->Length(), 5); Local<ArrayBuffer> ab = array->Buffer(); double* fields = static_cast<double*>(ab->GetBackingStore()->Data()); @@ -211,6 +214,8 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) { fields[1] = v8_heap_stats.total_heap_size(); fields[2] = v8_heap_stats.used_heap_size(); fields[3] = v8_heap_stats.external_memory(); + fields[4] = array_buffer_allocator == nullptr ? + 0 : array_buffer_allocator->total_mem_usage(); } void RawDebug(const FunctionCallbackInfo<Value>& args) { |