Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
src: skip weak references for memory tracking
The memory tracking is supposed to represent the “keeps-alive”
relations between objects for a heap dump, in order to enable
developers to figure out which objects keep which other objects
on the heap.

Weak references do not participate in that relation. Therefore,
we should not be tracking them.

PR-URL: #34469
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
addaleax authored and MylesBorins committed Jul 27, 2020
1 parent b12211e commit c05b63d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/memory_tracker-inl.h
Expand Up @@ -131,7 +131,7 @@ template <typename T, bool kIsWeak>
void MemoryTracker::TrackField(const char* edge_name,
const BaseObjectPtrImpl<T, kIsWeak>& value,
const char* node_name) {
if (value.get() == nullptr) return;
if (value.get() == nullptr || kIsWeak) return;
TrackField(edge_name, value.get(), node_name);
}

Expand Down Expand Up @@ -214,6 +214,7 @@ template <typename T>
void MemoryTracker::TrackField(const char* edge_name,
const v8::PersistentBase<T>& value,
const char* node_name) {
if (value.IsWeak()) return;
TrackField(edge_name, value.Get(isolate_));
}

Expand Down

0 comments on commit c05b63d

Please sign in to comment.