diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index d580f74478cbf7..657d16fbdca70c 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -1,6 +1,7 @@ #include "base_object-inl.h" #include "debug_utils-inl.h" #include "env-inl.h" +#include "memory_tracker-inl.h" #include "node.h" #include "node_errors.h" #include "node_internals.h" @@ -448,8 +449,10 @@ class FastHrtime : public BaseObject { Local obj = otmpl->NewInstance(env->context()).ToLocalChecked(); - Local ab = ArrayBuffer::New(env->isolate(), 12); - new FastHrtime(env, obj, ab->GetBackingStore()); + Local ab = + ArrayBuffer::New(env->isolate(), + std::max(sizeof(uint64_t), sizeof(uint32_t) * 3)); + new FastHrtime(env, obj, ab); obj->Set( env->context(), FIXED_ONE_BYTE_STRING(env->isolate(), "buffer"), ab) .ToChecked(); @@ -460,11 +463,16 @@ class FastHrtime : public BaseObject { private: FastHrtime(Environment* env, Local object, - std::shared_ptr backing_store) - : BaseObject(env, object), backing_store_(backing_store) {} - - void MemoryInfo(MemoryTracker* tracker) const override {} + Local ab) + : BaseObject(env, object), + array_buffer_(env->isolate(), ab), + backing_store_(ab->GetBackingStore()) { + MakeWeak(); + } + void MemoryInfo(MemoryTracker* tracker) const override { + tracker->TrackField("array_buffer", array_buffer_); + } SET_MEMORY_INFO_NAME(FastHrtime) SET_SELF_SIZE(FastHrtime) @@ -499,6 +507,7 @@ class FastHrtime : public BaseObject { FastBigInt(FromJSObject(args.Holder())); } + v8::Global array_buffer_; std::shared_ptr backing_store_; };