mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
perf_hooks: clean up GC listeners
Add Environment cleanup hooks to remove GC listeners when the `Environment` is torn down. PR-URL: https://github.com/nodejs/node/pull/25647 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 file changed
+5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user