From 808887da84a67e0f254fba57bd2d8d59a339fce8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 4 Nov 2017 22:25:18 +0100 Subject: [PATCH] src: use unrefed async for GC tracking Do not let an internal handle keep the event loop alive. Fixes: https://github.com/nodejs/node/issues/16210 --- src/node_perf.cc | 1 + test/parallel/test-performance-gc.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/node_perf.cc b/src/node_perf.cc index f5aafbab63a781..155f1e66e46bb9 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -215,6 +215,7 @@ void MarkGarbageCollectionEnd(Isolate* isolate, uv_async_t* async = new uv_async_t(); // coverity[leaked_storage] if (uv_async_init(env->event_loop(), async, PerformanceGCCallback)) return delete async; + uv_unref(reinterpret_cast(async)); async->data = new PerformanceEntry::Data(env, "gc", "gc", performance_last_gc_start_mark_, diff --git a/test/parallel/test-performance-gc.js b/test/parallel/test-performance-gc.js index 1ff4c9ae629942..89a9041c1c1159 100644 --- a/test/parallel/test-performance-gc.js +++ b/test/parallel/test-performance-gc.js @@ -48,4 +48,6 @@ const kinds = [ })); obs.observe({ entryTypes: ['gc'] }); global.gc(); + // Keep the event loop alive to witness the GC async callback happen. + setImmediate(() => setImmediate(() => 0)); }