"use strict";
function allocTest(alloc, allocAssert, deallocAssert) {
const sample = () => {
gc();
return Deno.memoryUsage();
};
const delta = (t1, t2) => t2.heapUsed - t1.heapUsed;
const t1 = sample();
let x = alloc();
const t2 = sample();
allocAssert(delta(t1, t2));
x = null;
const t3 = sample();
deallocAssert(delta(t2, t3));
}
function main() {
allocTest(
() => new Array(1e6),
(delta) => console.log("Allocated:", Math.round(delta / 1e6) + "MB"),
(delta) => console.log("Freed:", Math.round(delta / 1e6) + "MB"),
);
}
main();