Chrome DevTools Memory
Open DevTools → Memory tab (Chrome / Edge).
Heap snapshot
Section titled “Heap snapshot”Frozen picture of all objects on the heap.
Workflow:
- Snapshot A at baseline
- Perform suspect action 10×
- Force GC (trash icon)
- Snapshot B
- Select B → Comparison vs A
Look for # Delta growth in constructors: (string), Array, Detached HTMLElement, your app classes.
Allocation instrumentation on timeline
Section titled “Allocation instrumentation on timeline”Records allocations over time — great for when memory spiked during interaction.
- Start recording
- Reproduce leak
- Stop — inspect allocation bars on timeline
Allocation sampling
Section titled “Allocation sampling”Lower overhead — statistical view of hot allocators. Good for production-like profiling.
flowchart TD A[Baseline snapshot] --> B[Reproduce action] B --> C[Force GC] C --> D[Second snapshot] D --> E[Comparison view] E --> F[Find growing constructors]
What to look for
Section titled “What to look for”| Signal | Likely cause |
|---|---|
Detached * count rises |
DOM retention |
Closure / system / Context |
Callback leaks |
| Same listener count growing | Missing removeEventListener |
Array + your cache class |
Unbounded cache |