Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
perf_hooks: clean up GC listeners (#94)
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: nodejs/node#25647
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
brenca authored and codebytere committed Mar 5, 2019
1 parent 70a78f0 commit f807d72
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 f807d72

Please sign in to comment.