function
jsc.releaseWeakRefs
Releases the targets of WeakRefs so that a garbage collection can collect them immediately.
As the JavaScript specification requires, creating a WeakRef or calling its deref() keeps the target alive until the end of the current job (the current synchronous run of script). That is why a WeakRef created in the same script as a fullGC call still holds its target afterwards; calling this first lets the collection clear it.
import { fullGC, releaseWeakRefs } from "bun:jsc";
let target: object | null = {};
const ref = new WeakRef(target);
target = null;
fullGC();
ref.deref(); // still the object
releaseWeakRefs();
fullGC();
ref.deref(); // undefined