Skip to content

Commit

Permalink
perf_hooks: clean up GC listeners
Browse files Browse the repository at this point in the history
Add Environment cleanup hooks to remove GC listeners when the
`Environment` is torn down.

PR-URL: #25647
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed May 16, 2019
1 parent 48505d8 commit ff3d977
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ inline void SetupGarbageCollectionTracking(Environment* env) {
static_cast<void*>(env));
env->isolate()->AddGCEpilogueCallback(MarkGarbageCollectionEnd,
static_cast<void*>(env));
env->AddCleanupHook([](void* data) {
Environment* env = static_cast<Environment*>(data);
env->isolate()->RemoveGCPrologueCallback(MarkGarbageCollectionStart, data);
env->isolate()->RemoveGCEpilogueCallback(MarkGarbageCollectionEnd, data);
}, env);
}

// Gets the name of a function
Expand Down

0 comments on commit ff3d977

Please sign in to comment.