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 nitsakh committed Mar 18, 2019
1 parent 546db4a commit ceebcb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_binding.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);

NODE_EXTERN node_module* get_builtin_module(const char *name);
NODE_EXTERN node_module* get_linked_module(const char *name);

} // namespace binding

Expand Down
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 ceebcb8

Please sign in to comment.