demo · v140
Memory Watermark
An OOM crash that lands with no memory context is the worst kind. Snapshot the heap watermark and a count of active long-lived objects (canvases, audio nodes, observers) on every navigation — the moment the tab dies, the report carries the last good reading.
heap used
– MB
DOM nodes
–
active observers
–
awaiting crash
// Run on a 5-second tick or after every route change.
function snapshotMemory() {
if (performance.measureUserAgentSpecificMemory) {
performance.measureUserAgentSpecificMemory().then(r => {
crashReport.set("heap_mb", String(Math.round(r.bytes / 1e6)));
});
}
crashReport.set("dom_nodes", String(document.querySelectorAll("*").length));
crashReport.set("observers", String(activeObserverCount));
}
why a watermark
You don't ship a memory reading from inside the crash handler — by then the renderer is dead. You ship the last reading. Snapshot on every route change, every visibility change, and every WebGL context creation. When the report lands you can reconstruct: "this user was at 480 MB and 230k DOM nodes when their tab died." Way more actionable than "OOM."
see also
- Crash Reporting key-value API — feature index
- measureUserAgentSpecificMemory