Skip to content
Back to all posts
Technologydiagnose memory growth in React applications

Diagnosing React Memory Growth with Chrome DevTools

Use repeatable route tests, heap snapshots, allocation timelines, and retaining paths to locate objects that keep growing in a React application.

4 min readUpdated May 27, 2026AI-assisted

TechSilo

AI-assisted and human-curated

If a React application becomes slower after repeatedly opening a page, do not start by adding memo or rewriting components. First establish whether memory is actually being retained, then find the reference that prevents the browser from collecting it.

This guide focuses on the diagnosis workflow. For the cleanup patterns themselves, see [Memory Leaks in React: Causes, Cleanup, and Debugging](/blog/memory-leaks-in-react-applications-a-troubleshooting-guide-mqw8brv9).

Make the problem repeatable

Choose one user journey that seems to increase memory: open a dashboard, load a large table, navigate away, then return. Repeat the same sequence several times with the same data and browser conditions.

Record the baseline and the number of repetitions. A single high memory reading is not enough to prove a leak; browsers allocate memory for caches and may not immediately return it to the operating system. Look for a pattern where retained objects or post-GC heap usage continue to rise.

Disable unrelated extensions and close other tabs if they make the test noisy. Use a production-like build when development tooling changes the amount of memory allocated.

Compare heap snapshots

In Chrome DevTools:

1. Open the Memory panel.

2. Select Heap snapshot and capture a baseline.

3. Perform the repeatable user journey several times.

4. Return to the Memory panel and capture another snapshot.

5. Change the comparison selector to compare the later snapshot against the baseline.

Sort by Retained size or inspect the Comparison view for constructor groups whose object count increased. Retained size helps show how much memory would become collectible if an object and the references depending on it were released.

Do not assume the largest object is the leak. The important question is why it is still reachable.

Follow retaining paths

Select a suspicious object and inspect its retaining path. Common causes include:

- A listener registered on window or document that was never removed.

- A timer or interval that continues after a route changes.

- A WebSocket, observer, or subscription that was never closed.

- A module-level cache or global array that grows without a limit.

- A third-party widget that retains a DOM node after its container is removed.

A detached DOM tree is especially useful evidence: the node is no longer attached to the visible document, but something in JavaScript still references it.

Use allocation instrumentation for short-lived growth

A heap snapshot shows what is retained at a point in time. Allocation instrumentation on timeline can help when memory spikes during a specific interaction. Start recording, repeat the interaction, stop recording, and inspect allocations that remain live.

Use the timeline to narrow down the action that creates the objects. Then use a heap snapshot to investigate why the surviving objects are retained. These tools answer related but different questions.

Check effect cleanup in React

For each external resource created by an effect, identify its matching cleanup:

tsx
useEffect(() => {
  const controller = new AbortController();
  const onVisibilityChange = () => {
    console.log(document.visibilityState);
  };

  document.addEventListener('visibilitychange', onVisibilityChange);

  void fetch('/api/report', { signal: controller.signal });

  return () => {
    controller.abort();
    document.removeEventListener('visibilitychange', onVisibilityChange);
  };
}, []);

The example cancels the request and removes the listener when the effect is cleaned up. If an effect depends on props or state, remember that React also runs cleanup before re-running the effect with changed dependencies.

Verify the fix instead of guessing

After changing the suspected owner:

1. Repeat the exact same user journey.

2. Take another pair of snapshots.

3. Confirm the retained object count no longer grows with each repetition.

4. Check that the UI still works after repeated mount/unmount cycles.

5. Test slow network responses and error paths, not only the successful path.

React DevTools can help identify unnecessary renders, but a render optimization is not a memory-management fix. Use the browser Memory panel to prove that the retained objects have stopped accumulating.

Want to put this into practice?

Explore TechSilo's free developer tools for practical utilities you can use directly in your browser.

Related blog posts