From db39c8e109c58e44fd7a15f88fb510680352eea8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 2 Apr 2022 00:49:27 -0700 Subject: [PATCH] Create gc.js --- integration/bunjs-only-snippets/gc.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 integration/bunjs-only-snippets/gc.js diff --git a/integration/bunjs-only-snippets/gc.js b/integration/bunjs-only-snippets/gc.js new file mode 100644 index 0000000000..327b7d9a51 --- /dev/null +++ b/integration/bunjs-only-snippets/gc.js @@ -0,0 +1,14 @@ +export function gc() { + Bun.gc(true); +} + +// we must ensure that finalizers are run +// so that the reference-counting logic is exercised +export function gcTick(trace = false) { + trace && console.trace(""); + + gc(); + return new Promise((resolve) => { + setTimeout(resolve, 0); + }); +}