perf_hooks: avoid memory leak on gc observer

Fixes: https://github.com/nodejs/node/issues/22229

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
James M Snell authored and Rod Vagg committed 2018-08-15 20:23:17 +10:00
1 parent 1afcea107e
commit f570c19c89
1 file changed
+3
+3
View File
@@ -272,6 +272,9 @@ void MarkGarbageCollectionEnd(Isolate* isolate,
v8::GCCallbackFlags flags,
void* data) {
Environment* env = static_cast<Environment*>(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<PerformanceGCKind>(type),