aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/gc.js
diff options
context:
space:
mode:
Diffstat (limited to 'integration/bunjs-only-snippets/gc.js')
-rw-r--r--integration/bunjs-only-snippets/gc.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/integration/bunjs-only-snippets/gc.js b/integration/bunjs-only-snippets/gc.js
new file mode 100644
index 000000000..327b7d9a5
--- /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);
+ });
+}