Skip to content

Commit

Permalink
perf_hooks: avoid memory leak on gc observer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jasnell authored and rvagg committed Aug 15, 2018
1 parent 1afcea1 commit f570c19
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/node_perf.cc
Expand Up @@ -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),
Expand Down

0 comments on commit f570c19

Please sign in to comment.