Skip to content

Commit f570c19

Browse files
jasnellrvagg
authored andcommitted
perf_hooks: avoid memory leak on gc observer
Fixes: #22229 PR-URL: #22241 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: George Adams <george.adams@uk.ibm.com>
1 parent 1afcea1 commit f570c19

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)