Chrome Memory Inspector: How to Use It
In this article
To use Chrome's Memory Inspector, open DevTools (F12 or Ctrl+Shift+I on Windows/Linux, Cmd+Option+I on Mac), go to the Memory panel, select a profiling type (Heap snapshot, Allocation instrumentation, or Allocation sampling), click Start, perform the actions you want to analyze, then stop and inspect the results. The tool helps you find memory leaks, excessive DOM nodes, and inefficient JavaScript retention.
What Is the Chrome Memory Inspector?
The Memory panel in Chrome DevTools is a set of profilers that let you see how your web page uses memory. It is not a single button but a suite of three main tools, each answering a different question:
- Heap snapshot – Shows a snapshot of all JavaScript objects, DOM nodes, and closures at a specific moment. Use it to compare two snapshots to see what grew between actions.
- Allocation instrumentation on timeline – Records memory allocations over time, showing when new objects are created and whether they are later collected. Best for spotting leaks that happen gradually.
- Allocation sampling – Low-overhead sampling of allocations, useful for long-running pages where full instrumentation would slow things down.
These tools are part of Chrome DevTools, which is built into the browser. You do not need to install anything extra.
How to Open the Memory Panel
- Open the page you want to inspect in Chrome.
- Press F12 (or Ctrl+Shift+I on Windows/Linux, Cmd+Option+I on Mac) to open DevTools.
- Click the Memory tab in the top toolbar. If you don't see it, click the » (more tabs) icon and select it.
- You will see the profiling type selection screen. Choose one of the three options.
The exact labels may differ slightly across Chrome versions, but the core workflow has remained stable for years.
How to Take a Heap Snapshot
Heap snapshots are the most common starting point. They let you see what is currently in memory and identify objects that should have been garbage-collected.
- In the Memory panel, select Heap snapshot and click Take snapshot.
- Wait a few seconds – Chrome will freeze the page briefly to capture the state.
- The snapshot appears in the left sidebar. Click it to view the data.
- Use the dropdown at the top to switch between views: Summary (grouped by constructor), Comparison (diff between two snapshots), Containment (object graph), and Statistics (pie chart).
To find leaks, take a snapshot, do an action (like opening a modal), then take another snapshot. Switch to Comparison view and look for objects that were created but not freed. The # Delta column shows how many instances increased.
How to Record Allocation Timeline
This tool records every allocation in real time, letting you see exactly when memory grows and whether it is later reclaimed.
- Choose Allocation instrumentation on timeline.
- Click Start – a recording dot appears at the top of the screen.
- Perform the actions you want to test (e.g., clicking buttons, navigating, loading data).
- Click the red Stop button.
- You will see a timeline with blue bars representing allocations. Select a time range to see which objects were created.
Look for allocations that remain after the action is complete – those are potential leaks. The timeline also shows when garbage collection (GC) happens, marked by a gray line. If memory keeps growing without GC, that is a red flag.
How to Use Allocation Sampling
Allocation sampling is lighter on performance and is meant for production-like scenarios where you don't want to pause the page.
- Select Allocation sampling.
- Set the sampling interval (default is 32768 bytes, which is fine for most cases).
- Click Start, then interact with the page.
- Click Stop to see a statistical breakdown of where memory was allocated.
This is less precise than full instrumentation but helps you identify hot spots in your code without slowing down the page significantly.
Common Problems and How to Solve Them
Beginners often struggle with the following:
- Snapshots are huge – Filter by typing in the “Class filter” box, e.g., “detached” to find detached DOM nodes.
- Can't see what's leaking – Use the Containment view to trace the reference chain from the root (window) to the object. If an object is reachable from the root, it won't be garbage-collected.
- Memory inspector doesn't show everything – It only shows JavaScript heap, not native memory, GPU memory, or disk cache. For those, use the Performance monitor or the task manager (Shift+Esc).
- The page freezes during recording – This is normal for heap snapshots, but if it's too slow, try allocation sampling instead.
Comparing Memory Inspector with Other Tools
Chrome also has a Performance panel that records memory usage over time, but it focuses on CPU and rendering. The Memory panel is specifically for JavaScript heap analysis. For a quick look at memory usage, open the Chrome Task Manager (Shift+Esc) – it shows live memory per tab, but no details. For more advanced profiling, you might use the --js-flags command-line switches, but that's beyond typical needs.
Frequently Asked Questions
How do I find memory leaks in Chrome?
Take two heap snapshots – one before and one after repeating an action several times. In the Comparison view, look for objects with a positive delta that should have been freed. If they persist after garbage collection, they are likely leaked.
What is a detached DOM node?
A detached DOM node is an HTML element that has been removed from the document but is still referenced by JavaScript. It stays in memory because the reference keeps it alive. You can find them by filtering the heap snapshot for “detached”.
Why does my page use so much memory?
Common causes include large images, too many DOM nodes, unoptimized JavaScript, and memory leaks. Use the Memory panel to see which objects dominate, and the Performance panel to see when memory spikes occur.
Can I use the Memory Inspector on a production site?
Yes, but be aware that heap snapshots pause the page. For production, use allocation sampling or the Performance monitor to avoid disrupting users. You can also use remote debugging to inspect a live site.
Is there a way to clear memory in Chrome?
You can force garbage collection in DevTools by clicking the trash icon in the Memory panel, or by pressing the “Collect garbage” button. However, this only clears objects that are unreachable – it won't fix leaks.
Does the Memory Inspector work for service workers?
Yes, the Memory panel shows the JavaScript heap of the page, including any service worker contexts. You can switch the execution context dropdown at the top of the Memory panel to select a service worker.