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

Commit ceebcb8

Browse files
brencanitsakh
authored andcommitted
perf_hooks: clean up GC listeners (#94)
Add Environment cleanup hooks to remove GC listeners when the `Environment` is torn down. PR-URL: nodejs/node#25647 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 546db4a commit ceebcb8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/node_binding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
5656
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
5757
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);
5858

59-
NODE_EXTERN node_module* get_builtin_module(const char *name);
59+
NODE_EXTERN node_module* get_linked_module(const char *name);
6060

6161
} // namespace binding
6262

src/node_perf.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ inline void SetupGarbageCollectionTracking(Environment* env) {
296296
static_cast<void*>(env));
297297
env->isolate()->AddGCEpilogueCallback(MarkGarbageCollectionEnd,
298298
static_cast<void*>(env));
299+
env->AddCleanupHook([](void* data) {
300+
Environment* env = static_cast<Environment*>(data);
301+
env->isolate()->RemoveGCPrologueCallback(MarkGarbageCollectionStart, data);
302+
env->isolate()->RemoveGCEpilogueCallback(MarkGarbageCollectionEnd, data);
303+
}, env);
299304
}
300305

301306
// Gets the name of a function

0 commit comments

Comments
 (0)