Skip to content

Commit 977f9e6

Browse files
committed
perf_hooks: avoid memory leak on gc observer
Fixes: nodejs#22229
1 parent fe47b8b commit 977f9e6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/node_perf.cc

+3
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ void MarkGarbageCollectionEnd(Isolate* isolate,
272272
v8::GCCallbackFlags flags,
273273
void* data) {
274274
Environment* env = static_cast<Environment*>(data);
275+
// If no one is listening to gc performance entries, do not create them.
276+
if (!env->performance_state()->observers[NODE_PERFORMANCE_ENTRY_TYPE_GC])
277+
return;
275278
GCPerformanceEntry* entry =
276279
new GCPerformanceEntry(env,
277280
static_cast<PerformanceGCKind>(type),

0 commit comments

Comments
 (0)