Skip to content

Commit

Permalink
perf_hooks: avoid memory leak on gc observer
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Aug 10, 2018
1 parent fe47b8b commit 977f9e6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
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 977f9e6

Please sign in to comment.