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 <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Jan 28, 2019
1 parent 845bcfa commit fc38b20
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 fc38b20

Please sign in to comment.