Investigate runtime performance, memory and storage
Find Objects That Survive a Reversed Page Action With Chrome Heap Snapshots
Compare Chrome heap snapshots before and after opening and closing a panel, then inspect surviving objects and detached DOM trees.

If objects seem to remain after a user closes part of your page, take a Chrome DevTools heap snapshot before the interaction, repeat the action and its reversal, then compare a second snapshot against the first. Expand changed entries and inspect Retainers to find what points to an object that remains. The comparison gives you a lead to investigate, not a verdict that the page leaks memory.
Use a page state you can reproduce. For this example, start with a panel closed, open it, then close it again. Both snapshots should be taken with the panel closed. Otherwise, you may simply be comparing a closed panel with an open one.
Capture a baseline snapshot in the Memory panel
Open the page in Chrome DevTools and go to the Memory panel. Select Heap snapshot as the profiling type, select the JavaScript VM instance for the page you are investigating, and click Take snapshot. When processing finishes, select the result from the Heap snapshots list. This is your baseline, Snapshot 1. Chrome’s heap snapshot instructions describe this capture flow.
Do not open the panel as part of setting up this baseline. Leave it in the closed state that you intend to restore later. If the page cannot return to a comparable state after the action, the difference between snapshots will be harder to interpret.
Taking a snapshot starts with garbage collection, and the snapshot shows objects in the memory graph that are reachable from the global object. That matters when reading the result: you are examining what is present at each capture point, not a log of every object created while the panel was open.
Repeat and reverse one page action, then capture a second snapshot
With Snapshot 1 captured, open the panel and close it. Repeat that same open-then-close sequence a few times, finishing with the panel closed. Now click Take snapshot again. Wait for Snapshot 2 to appear in the Heap snapshots list and select it.
Change Snapshot 2 to Comparison view and compare it against Snapshot 1. You should now have two snapshots in the list, with the second snapshot’s Comparison view set against the first. Chrome documents this before-operation, operation-and-reversal, after-operation sequence as a way to investigate suspected leaks.
Keep the sequence narrow. If you also navigate, load different content, or leave the panel open before the second capture, the snapshots answer a different question. In this example, the question is specifically what remains after repeated openings and closings of the panel.
Compare added and deleted instances and inspect their Retainers
In Comparison view, look for entries that changed between the two snapshots. Expand a total entry to see its added and deleted object instances. An added instance is a useful place to begin when you expected the reversed action to leave nothing related to the panel behind. A deleted instance is useful context: the view is showing changes in both directions, not just accumulation.
Select an instance you want to investigate and inspect Retainers at the bottom of the Memory panel. Retainers shows objects that point to the selected object. Follow those references to ask a more specific question than “Did the number go up?”: what still points to this object when the panel is closed? The Chrome comparison documentation describes both the added and deleted instances and the Retainers section.
A positive difference by itself does not establish a leak. The two snapshots show reachable objects at two points after garbage collection; the comparison does not, on its own, tell you whether a surviving object is unexpectedly retained. Use the selected object and its Retainers to form a hypothesis, then check whether it survives another controlled run of the same interaction.
Check suspected detached DOM trees and repeat the test
If the surviving entries make you suspect DOM retention, type Detached into the Class filter to search for detached DOM trees in the snapshot. Chrome’s Memory troubleshooting guide documents this filter. Select an interesting result and inspect its Retainers, just as you would for another changed object.
Then return to the same starting state and repeat the open-then-close test. Capture a fresh baseline with the panel closed, repeat the same action and reversal a few times, and compare a new closed-state snapshot against that baseline. If the suspected objects persist across this controlled repeat, treat them as leak candidates worth tracing, not as proof based only on a count or a single comparison. The useful outcome is a concrete object and a reference to investigate, rather than a larger number with no explanation.
