JSFiddle - React, Tailwind, and code Playground

CSS

pre { margin: 0; }

JavaScript

function makeThing() {
  const t = new Float32Array();
  return new WeakRef(t);
}

const ref = makeThing();
const id = setInterval(check, 1000);

function check() {
  log(`elapsedTime: ${(performance.now() * 0.001).toFixed(1)}s`);
  if (!ref.deref()) {
    clearInterval(id);
    log('GCed');
  }
}

function log(...args) {
  const elem = document.createElement('pre');
  elem.textContent = args.join(' ');
  document.body.appendChild(elem);
}