Skip to content

Commit

Permalink
src: use unrefed async for GC tracking
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
addaleax authored and MylesBorins committed Nov 17, 2017
1 parent 8f0793f commit 4088089
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<uv_handle_t*>(async));
async->data =
new PerformanceEntry::Data(env, "gc", "gc",
performance_last_gc_start_mark_,
Expand Down
2 changes: 2 additions & 0 deletions test/parallel/test-performance-gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

0 comments on commit 4088089

Please sign in to comment.