How to See DOM Node Count and Memory Growth in Chrome DevTools
When a page gets heavier every time you press a button, you can use the Performance monitor in Chrome DevTools to watch the growth of the DOM node count (DOM nodes), the JavaScript heap size (JS heap size), and the event listener count (JS event listeners) live. Unlike the Performance panel, you don't have to start and stop a recording. You can keep interacting with the page while watching the numbers and graphs. When you suspect a memory leak, force garbage collection after the operation and check whether the numbers return to their previous level. That gives a good idea of whether memory is leaking.
The test environment was Ubuntu 24.04 with Chrome for Testing 153.0.8010.12 (the build bundled with Playwright). I docked DevTools to the bottom of the window (Dock to bottom). The DevTools UI was in English, so I use the English menu and item names. The page was served from a local HTTP server (http://localhost:8080/). I did not test how to read other items such as CPU usage, Documents, or Layouts / sec, pages built with libraries like React, or Chrome on macOS and Windows.
Open the Performance monitor
As described in the official documentation for the Performance monitor, open it from the command menu.
- Open DevTools and press Ctrl+Shift+P (Command+Shift+P on macOS) to open the command menu.
- Type
Performance monitor, select Show Performance monitor, and press Enter.
In the test environment, the Performance monitor opened as a tab in the drawer at the bottom of DevTools. When the window was 800px wide, the drawer appeared on the right side of DevTools in a tall layout, and the graphs were only about 70px wide. In that case, press the Toggle drawer orientation button at the top right of the drawer, and it will move to a wide layout below DevTools.
Right after opening, the list on the left had CPU usage, JS heap size, and DOM nodes checked. Clicking an item name toggles whether it appears in the graph on the right. Here I unchecked CPU usage, checked JS event listeners, and displayed JS heap size, DOM nodes, and JS event listeners together. The values update about every 0.5 seconds (in the DevTools source code, the sampling interval is 500 milliseconds).
Watch the growth each time you press a button
The page I tested rebuilds a list of 200 products each time you press the "Next 200" button. To allow going back to earlier pages, it keeps the lists removed from the screen in an array called pages.
const pages = []; // Keep the list we made so we can use it when going back to the previous page.
let page = 0;
function showNext() {
page++;
const items = [];
for (let i = 1; i <= 200; i++) {
items.push({ id: page * 1000 + i, name: `商品 ${page}-${i}`, data: new Array(1000).fill(page * 1000 + i) });
}
const list = document.createElement('ul');
for (const item of items) {
const li = document.createElement('li');
li.textContent = item.name;
li.addEventListener('click', () => console.log(item.id));
list.appendChild(li);
}
const slot = document.getElementById('slot');
if (slot.firstChild) pages.push(slot.firstChild);
slot.replaceChildren(list);
document.getElementById('count').textContent = `${page} 回目`;
}
document.getElementById('next').addEventListener('click', showNext);
With the Performance monitor open, I pressed the button 10 times.

The values in the list on the left changed as follows.
| Point in time | JS heap size | DOM nodes | JS event listeners |
|---|---|---|---|
| Before pressing | 3.1 MB | 53 | 18 |
| After the 1st press | 5.2 MB | 655 | 220 |
| After the 2nd press | 6.0 MB | 1,257 | 426 |
| After the 3rd press | 9.7 MB | 1,859 | 630 |
| After the 10th press | 16.8 MB | 4,649 | 2,019 |
Until the 8th press, DOM nodes increased by 602 with each press, and the graph formed a staircase that rose one step per press. Only after the 9th press did it drop, from 4,869 to 4,047. This happened because the browser ran garbage collection on its own between the 8th and 9th presses. I compare this with a page that does not keep old lists in the next section. JS event listeners increased by about 200 with each press, except at the 9th press.
JS heap size did not increase by the same amount each time. It stayed at 9.7 MB from the 3rd to the 5th press, then jumped to 16.3 MB at the 7th press. The JS heap size value in the list on the left is not the amount JavaScript is currently using. It is the total size of the heap allocated (in the DevTools source code, the value used for display is JSHeapTotalSize). The graph draws two things on top of each other: the total allocated (the light purple filled area) and the amount in use within it (the dark purple line). When I read the values for the same point in time directly from the page (Performance.getMetrics in the Chrome DevTools Protocol), after the 10th press the total allocated was 16.78 MB and the amount in use was 9.91 MB.
Use the values after garbage collection to tell whether memory is leaking
Seeing growth alone does not prove a memory leak. For comparison, I pressed the button 10 times on a page where I removed the two lines that keep pages.
-const pages = []; // Keep the list we made so we can use it when going back to the previous page.
let page = 0;
...
const slot = document.getElementById('slot');
- if (slot.firstChild) pages.push(slot.firstChild);
slot.replaceChildren(list);
On this page, until the 8th press, the numbers were nearly the same as the page that keeps the lists (after the 7th press: JS heap size 16.0 MB, DOM nodes 4,267). On both pages, the browser ran garbage collection on its own between the 8th and 9th presses. Looking at the values after the 9th press, the page that does not keep the lists dropped DOM nodes from 4,869 to 1,240, while the page that keeps them only dropped to 4,047. However, when garbage collection runs depends on the browser. If you compare only the graph while pressing buttons, it is hard to tell which page is leaking.
So after pressing the button 10 times, I forced garbage collection. I opened the Memory panel in DevTools, and in the row of buttons at the top, I pressed Collect garbage, the button with the mop-shaped icon. After pressing it, "Garbage collection completed" appeared at the bottom left of DevTools. Because the Performance monitor is open in the drawer, I could keep watching the values after switching to the Memory panel above.


The values 3 seconds after pressing Collect garbage were as follows.
| Page | JS heap size | DOM nodes | JS event listeners |
|---|---|---|---|
| Keeps the lists | 10.7 MB | 4,247 | 2,014 |
| Does not keep the lists | 3.1 MB | 638 | 212 |
The page that does not keep the lists returned to 638 DOM nodes and 212 JS event listeners. This is nearly the same as the values after the 1st press on this page (655 and 221). The page that keeps the lists stayed at 4,247 DOM nodes. The difference of 3,609 matches exactly the lists for the 9 pages removed from the screen (1 <ul>, 200 <li>, and the 200 text nodes inside the <li> elements, which is 401 per page). The difference in JS event listeners (about 1,800) also matches the number of listeners attached to the <li> elements of those 9 pages.
To check whether memory stays high after growth, compare the values after forced garbage collection. The official documentation section on finding memory leaks with the Performance panel also describes a method: use the value after garbage collection as the baseline, and if the final value is higher, suspect a leak.
The JS heap size also showed a clear difference: 10.7 MB for the page that keeps the lists and 3.1 MB for the page that does not. However, this number is the total allocated size, so it swings more widely than the amount in use. The amount in use at the same point in time (JSHeapUsedSize from Performance.getMetrics) was 9.82 MB for the page that keeps the lists and 2.39 MB for the page that does not.
The Performance monitor shows what is growing and which operation makes it grow. To find which code holds on to the elements, take a heap snapshot in the Memory panel.





