diff --git a/src/node_perf.cc b/src/node_perf.cc index 5a50223ed593c2..9c995d3b8de603 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),