Skip to content

Commit a79d86d

Browse files
addaleaxevanlucas
authored andcommittedNov 13, 2017
src: use unrefed async for GC tracking
Do not let an internal handle keep the event loop alive. PR-URL: #16758 Fixes: https://github.com/node/issues/16210 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 74f3372 commit a79d86d

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
 

‎src/node_perf.cc

+1
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ void MarkGarbageCollectionEnd(Isolate* isolate,
215215
uv_async_t* async = new uv_async_t(); // coverity[leaked_storage]
216216
if (uv_async_init(env->event_loop(), async, PerformanceGCCallback))
217217
return delete async;
218+
uv_unref(reinterpret_cast<uv_handle_t*>(async));
218219
async->data =
219220
new PerformanceEntry::Data(env, "gc", "gc",
220221
performance_last_gc_start_mark_,

‎test/parallel/test-performance-gc.js

+2
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ const kinds = [
4848
}));
4949
obs.observe({ entryTypes: ['gc'] });
5050
global.gc();
51+
// Keep the event loop alive to witness the GC async callback happen.
52+
setImmediate(() => setImmediate(() => 0));
5153
}

0 commit comments

Comments
 (0)