diff --git a/src/node_perf.cc b/src/node_perf.cc index a1ca57e2d5c100..5d94bb4c8a4a56 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -272,6 +272,9 @@ void MarkGarbageCollectionEnd(Isolate* isolate, v8::GCCallbackFlags flags, void* data) { Environment* env = static_cast(data); + // If no one is listening to gc performance entries, do not create them. + if (!env->performance_state()->observers[NODE_PERFORMANCE_ENTRY_TYPE_GC]) + return; GCPerformanceEntry* entry = new GCPerformanceEntry(env, static_cast(type),