Skip to content

Commit ff3d977

Browse files
addaleaxMylesBorins
authored andcommitted
perf_hooks: clean up GC listeners
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]>
1 parent 48505d8 commit ff3d977

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/node_perf.cc

+5
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)