Skip to content

Commit

Permalink
src: skip weak references for memory tracking
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
addaleax committed Sep 22, 2020
1 parent e52cc24 commit 9f46500
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/memory_tracker-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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 @@ -204,6 +204,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 9f46500

Please sign in to comment.