Permalink
Browse files

perf_hooks: clean up GC listeners

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 committed Jan 22, 2019
1 parent e3e4048 commit acc5a86efe241b52a2e0bf8c6b1ba886213cf9f0
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/node_perf.cc
@@ -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

0 comments on commit acc5a86

Please sign in to comment.