Skip to content

Commit 4088089

Browse files
addaleaxMylesBorins
authored andcommittedNov 17, 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 <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 8f0793f commit 4088089

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)
Please sign in to comment.