Skip to content

Commit c05b63d

Browse files
addaleaxMylesBorins
authored andcommitted
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent b12211e commit c05b63d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/memory_tracker-inl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ template <typename T, bool kIsWeak>
131131
void MemoryTracker::TrackField(const char* edge_name,
132132
const BaseObjectPtrImpl<T, kIsWeak>& value,
133133
const char* node_name) {
134-
if (value.get() == nullptr) return;
134+
if (value.get() == nullptr || kIsWeak) return;
135135
TrackField(edge_name, value.get(), node_name);
136136
}
137137

@@ -214,6 +214,7 @@ template <typename T>
214214
void MemoryTracker::TrackField(const char* edge_name,
215215
const v8::PersistentBase<T>& value,
216216
const char* node_name) {
217+
if (value.IsWeak()) return;
217218
TrackField(edge_name, value.Get(isolate_));
218219
}
219220

0 commit comments

Comments
 (0)