Summary
Heap snapshot diff — detached DOM, growing listeners, closures holding large graphs. Performance monitor JS heap trend over SPA navigations. Common: charts, maps, global caches without eviction. Fix teardown in useEffect return and route leave.
Code example
const baseline = performance.memory?.usedJSHeapSize;
function checkLeak() {
const current = performance.memory?.usedJSHeapSize;
if (baseline && current - baseline > 5_000_000) {
console.warn('Heap grew by', current - baseline, 'bytes');
}
}
Key points
- Heap snapshot diff — detached DOM, growing listeners, closures holding large graphs.
- Performance monitor JS heap trend over SPA navigations.
- Common: charts, maps, global caches without eviction.
- Fix teardown in
useEffectreturn and route leave.