You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory leak on 1.6.0 (no autoConnect): main-isolate old space grows ~13 MiB/min per active session, plateaus when idle, cyclic heap-limit OOMs #2431
I am aware #1192 was closed as completed. I verified the devtools-frontend fix is present in the 1.6.0 bundle (isPrimaryFrame() in build/src/third_party/index.js has the corrected form). The behavior below persists on 1.6.0, so either this is a different retention path of the same class, or the fix does not cover this usage pattern (no --autoConnect involved).
Instrumentation and data
I injected a sampler into the process via NODE_OPTIONS --import that logs v8.getHeapStatistics() + old_space every 30 s per isolate (main and worker threads tagged separately), plus a per-tool-call log for correlation. Main-isolate old_space over one afternoon cycle (UTC):
time
old_space (MiB)
note
18:48
27
fresh start
19:18
209
active load
19:48
370
active load
20:18
573
active load
20:48–21:18
~565
idle period — no growth
21:48
727
load resumes
22:07
1296
+569 MiB in 22 min
Key observations:
Growth is strictly correlated with activity and fully plateaus when idle — consistent with per-event/per-request data being retained, not a timer-based leak.
Worker threads (formatter / heap_snapshot / wasmparser from the bundled devtools-frontend) appear in transient bursts (~20 alive for ~40 min under snapshot-heavy load) and are properly terminated — they inflate RSS temporarily but do not explain the main-isolate old_space march.
Question
Is per-target network/event data (or another per-navigation structure) in the bundled devtools-frontend still unbounded on some path exercised by navigation + screenshots + script evaluation? Happy to run additional instrumentation or test patches — this setup reproduces the growth reliably within a few hours of normal agent workload.
Additional data point narrowing the mechanism: we captured an OOM where the fatal growth happened with no tool call in flight.
Timeline (heap sampled every 30 s on the main isolate, --max-old-space-size=1536):
23:52:34 — last tool call of the cycle completes (a 175 ms screenshot)
23:53:55 — old space 906 MiB, stable
23:54:25 — old space 905 MiB, stable
23:54:50 — FATAL ERROR: Reached heap limit — +~440 MiB in ~25 s, more than 2 minutes after the last tool call
The only activity during that window was background CDP event traffic from open pages (heavy SPAs that poll continuously). So the retention appears to be event-driven, not call-driven: pages left open keep pumping network/console events and something in the bundled devtools-frontend model accumulates them until the isolate hits the heap limit. Tool calls correlate with growth mainly because they open/navigate pages that then generate event traffic.
This also matches the earlier observation that growth plateaus only when the browser itself is quiet, not merely when the MCP client is idle.
Thanks for reporting. @milordy-coutinho do you have a script (using an MCP client for instance) that could help reproduce the memory leak? And to confirm you are not using screencast commands? Note that the MCP server retains network data for up to 3 navigations. If you have really a lot of traffic on a page you might need more memory. The memory should be cleaned if you navigate away or close the page. Do you observe this?
Reproduced this deterministically and bisected it to a specific line. Short version: the growth is not the network or console collectors, it is the DevTools universe that McpPage creates for every page in the browser.
Reproduction
Attach to an already running Chrome that has a realistic set of tabs open (mine had 18: Teams x2, Jira x3, Gmail x2, Telegram, YouTube Music, a few SPAs). Start the server, make exactly onelist_pages call, then go completely idle and sample RSS.
[repro] list_pages done, rss before=142.8MB
[repro] going idle now -- no further tool calls
[repro] t=20s rss=2186.0MB
[repro] t=35s rss=3242.1MB
[repro] t=50s rss=NaNMB <- process gone, OOM at the 3 GB cap
That is roughly 100 MB/s with zero tool calls in flight, which matches @milordy-coutinho's observation that the fatal growth happens minutes after the last call. The fatal stack is the giveaway:
The heap is going into parsing inbound CDP messages, so something is subscribed to a very chatty CDP domain across many targets.
Bisect
I replicated each step of McpPage's setup separately against the same live browser, 18 pages, 60 s, no tool calls:
what was done per page
RSS over 60 s
NetworkCollector + ConsoleCollector only (no init())
flat, 140 MB
page.createCDPSession() only
flat, 125 MB
page.emulateFocusedPage(true)
flat, 140 MB
createTargetUniverse(session)
200 MB -> 1736 MB in 10 s, OOM at the 2 GB cap by ~19 s
So the collectors are not involved. Worth noting for #2435: the per-navigation request cap is a good change on its own, but it does not touch this. In my run the collectors accumulated 219 requests and 48 console messages in 90 s, nowhere near the 1,000 limit, while RSS was already in gigabytes.
Root cause
McpPage.init() calls #initDevToolsUniverseNoThrow() for every page, and createTargetUniverse() does:
Force-starting DebuggerModel sends Debugger.enable on the page. The browser then replays every script the page has ever parsed and keeps streaming Debugger.scriptParsed for new ones, and DevTools retains each script. On a script-heavy SPA that is a continuous stream, and it is multiplied by the number of tabs that happen to be open, because createPagesSnapshot() builds an McpPage for all of them.
The universe is only consumed in two places (McpResponse, to symbolicate stack traces for the page being reported on, and the secondary session for CPU throttling), and devTools: undefined is already a supported input there, since #initDevToolsUniverseNoThrow swallows failures. So the universe does not need to exist for pages nobody is looking at.
This also explains the shape people reported: it is event driven rather than call driven, it plateaus when the browser is quiet, and the rate varies enormously between users because it depends entirely on how many tabs are open and how much script they parse.
Fix
PR: #2463. It creates the universe on demand instead of in init(). selectPage() warms it for the page being worked on, the two consumers await it, and McpPage.dispose() detaches its CDP session so closed tabs stop being tracked. That turns N universes into 1.
Both reproduction scripts are in the PR description if you want to run them yourselves.
@Dmitriusan did you dive into what is it that causes the leak within the DevToolsUniverse instances? I would expect the memory usage to also remain stable with DevTools Universe being on.
Dug into your question, and I've updated #2463 with a different approach based on the answer.
Short version: it is automatic source map loading, and it is not really a leak. It is a large, retained, one-off cost per page. Your expectation holds for most pages and breaks on pages that ship source maps.
What it is
DebuggerModel.parsedScriptSource() calls attachSourceMap() for every script carrying a sourceMapURL, since SourceMapManager defaults to enabled and nothing turns it off. Each map is downloaded, VLQ decoded, sorted, reverse mapped, and the decoded mappings stay alive as long as the model does.
One Jira issue page, one universe, forcing a full GC every second so this is retention and not GC lag:
Supporting evidence: 147 of the 147 Network.loadNetworkResource calls the universe made in 8 seconds were .map files, plus 561 IO.read calls streaming them back; the CPU profile of the growth window is dominated by parseSourceMap, #computeReverseMappings and nextVLQ.
That plateau is the "plateaus when idle" from the original report. Growth stops once the page runs out of new scripts. And the wildly different rates people report are just whether the app ships source maps: on the same browser, Jira 2.4 GB retained, Azure DevOps roughly zero, Teams and Gmail flat. The multiplier is createPagesSnapshot() building an McpPage for every page in the browser, so that bill is paid per open tab.
The updated PR
#2463 now leaves universe creation alone. The universe only needs source maps to symbolicate the frames of a stack trace it is about to format, and createStackTrace() already walks exactly those scripts, so the PR refuses developer resource loads by default and attaches the map for one script when it is needed.
It is tested and works in the case that was failing on my machine: my daily browser with 18 ordinary tabs open, where main goes to 4.9 GB and OOMs within a minute of a single list_pages call. On the branch it settles at 210 MB and stays there, with all 18 pages still getting a universe. Stack traces come out byte for byte identical against a fixture with a real source map, and get_console_message on a 2.8 MB map got faster rather than slower (1893/1882/2340 ms -> 133/139/142 ms, three runs each). No new test failures.
Two traps, in case they save someone time. Blocking the CDP Network.loadNetworkResource command alone changes nothing, because PageResourceLoader.dispatchLoad() falls back to loadFromHostBindings(), so the download just reroutes. And SourceMapManager.setEnabled(false) cannot be toggled around a symbolication, because setEnabled(true) re-attaches every registered client at once.
Separately, the uncaught Unknown session crash I mentioned is now #2466 with a regression test. Unrelated to this, I just kept hitting it while measuring.
Verified source maps served from Jira is bloating the memory because of eager loading, as @Dmitriusan had pointed out. To fix this
we are adding a feature to lazy load the source map in the upstream (link), and I will update the MCP server once that's reflected here.
Separately, there are other sources of memory leak: 1) not properly disposing IsolatedFileSystemManager, and 2) not unregistering handlers in PuppeteerDevToolsConnection. #2465 attempts to fix both but we will abandon that and fill fix those in the upstream instead (link, and more coming).
It seems there are multiple instances of memory leaks / unexpected increase in memory already. We will update the regression tests in scripts/eval_scenarios to be able to better prevent / catch instances like this in the future.
Thanks to everyone who contributed debugging this issue! Please keep the reports coming if you all see anything :)
Activity
milordy-coutinho commentedon Jul 28, 2026
Additional data point narrowing the mechanism: we captured an OOM where the fatal growth happened with no tool call in flight.
Timeline (heap sampled every 30 s on the main isolate,
--max-old-space-size=1536):FATAL ERROR: Reached heap limit— +~440 MiB in ~25 s, more than 2 minutes after the last tool callThe only activity during that window was background CDP event traffic from open pages (heavy SPAs that poll continuously). So the retention appears to be event-driven, not call-driven: pages left open keep pumping network/console events and something in the bundled devtools-frontend model accumulates them until the isolate hits the heap limit. Tool calls correlate with growth mainly because they open/navigate pages that then generate event traffic.
This also matches the earlier observation that growth plateaus only when the browser itself is quiet, not merely when the MCP client is idle.
OrKoN commentedon Jul 28, 2026
Thanks for reporting. @milordy-coutinho do you have a script (using an MCP client for instance) that could help reproduce the memory leak? And to confirm you are not using screencast commands? Note that the MCP server retains network data for up to 3 navigations. If you have really a lot of traffic on a page you might need more memory. The memory should be cleaned if you navigate away or close the page. Do you observe this?
fix: bound per-navigation network request retention
fix: bound per-navigation network request retention (ChromeDevTools#2435
fix: create the DevTools universe on demand instead of per page
Dmitriusan commentedon Aug 3, 2026
Reproduced this deterministically and bisected it to a specific line. Short version: the growth is not the network or console collectors, it is the DevTools universe that
McpPagecreates for every page in the browser.Reproduction
Attach to an already running Chrome that has a realistic set of tabs open (mine had 18: Teams x2, Jira x3, Gmail x2, Telegram, YouTube Music, a few SPAs). Start the server, make exactly one
list_pagescall, then go completely idle and sample RSS.That is roughly 100 MB/s with zero tool calls in flight, which matches @milordy-coutinho's observation that the fatal growth happens minutes after the last call. The fatal stack is the giveaway:
The heap is going into parsing inbound CDP messages, so something is subscribed to a very chatty CDP domain across many targets.
Bisect
I replicated each step of
McpPage's setup separately against the same live browser, 18 pages, 60 s, no tool calls:NetworkCollector+ConsoleCollectoronly (noinit())page.createCDPSession()onlypage.emulateFocusedPage(true)createTargetUniverse(session)So the collectors are not involved. Worth noting for #2435: the per-navigation request cap is a good change on its own, but it does not touch this. In my run the collectors accumulated 219 requests and 48 console messages in 90 s, nowhere near the 1,000 limit, while RSS was already in gigabytes.
Root cause
McpPage.init()calls#initDevToolsUniverseNoThrow()for every page, andcreateTargetUniverse()does:Force-starting
DebuggerModelsendsDebugger.enableon the page. The browser then replays every script the page has ever parsed and keeps streamingDebugger.scriptParsedfor new ones, and DevTools retains each script. On a script-heavy SPA that is a continuous stream, and it is multiplied by the number of tabs that happen to be open, becausecreatePagesSnapshot()builds anMcpPagefor all of them.The universe is only consumed in two places (
McpResponse, to symbolicate stack traces for the page being reported on, and the secondary session for CPU throttling), anddevTools: undefinedis already a supported input there, since#initDevToolsUniverseNoThrowswallows failures. So the universe does not need to exist for pages nobody is looking at.This also explains the shape people reported: it is event driven rather than call driven, it plateaus when the browser is quiet, and the rate varies enormously between users because it depends entirely on how many tabs are open and how much script they parse.
Fix
PR: #2463. It creates the universe on demand instead of in
init().selectPage()warms it for the page being worked on, the two consumers await it, andMcpPage.dispose()detaches its CDP session so closed tabs stop being tracked. That turns N universes into 1.Both reproduction scripts are in the PR description if you want to run them yourselves.
OrKoN commentedon Aug 3, 2026
cc @szuend
OrKoN commentedon Aug 3, 2026
@Dmitriusan did you dive into what is it that causes the leak within the DevToolsUniverse instances? I would expect the memory usage to also remain stable with DevTools Universe being on.
Dmitriusan commentedon Aug 3, 2026
Hi @OrKoN,
Dug into your question, and I've updated #2463 with a different approach based on the answer.
Short version: it is automatic source map loading, and it is not really a leak. It is a large, retained, one-off cost per page. Your expectation holds for most pages and breaks on pages that ship source maps.
What it is
DebuggerModel.parsedScriptSource()callsattachSourceMap()for every script carrying asourceMapURL, sinceSourceMapManagerdefaults to enabled and nothing turns it off. Each map is downloaded, VLQ decoded, sorted, reverse mapped, and the decoded mappings stay alive as long as the model does.One Jira issue page, one universe, forcing a full GC every second so this is retention and not GC lag:
2427 MB, then flat forever. Adding one line right after
createTargetUniverse():gives 59 MB instead. Everything else identical.
Supporting evidence: 147 of the 147
Network.loadNetworkResourcecalls the universe made in 8 seconds were.mapfiles, plus 561IO.readcalls streaming them back; the CPU profile of the growth window is dominated byparseSourceMap,#computeReverseMappingsandnextVLQ.That plateau is the "plateaus when idle" from the original report. Growth stops once the page runs out of new scripts. And the wildly different rates people report are just whether the app ships source maps: on the same browser, Jira 2.4 GB retained, Azure DevOps roughly zero, Teams and Gmail flat. The multiplier is
createPagesSnapshot()building anMcpPagefor every page in the browser, so that bill is paid per open tab.The updated PR
#2463 now leaves universe creation alone. The universe only needs source maps to symbolicate the frames of a stack trace it is about to format, and
createStackTrace()already walks exactly those scripts, so the PR refuses developer resource loads by default and attaches the map for one script when it is needed.It is tested and works in the case that was failing on my machine: my daily browser with 18 ordinary tabs open, where
maingoes to 4.9 GB and OOMs within a minute of a singlelist_pagescall. On the branch it settles at 210 MB and stays there, with all 18 pages still getting a universe. Stack traces come out byte for byte identical against a fixture with a real source map, andget_console_messageon a 2.8 MB map got faster rather than slower (1893/1882/2340 ms -> 133/139/142 ms, three runs each). No new test failures.Two traps, in case they save someone time. Blocking the CDP
Network.loadNetworkResourcecommand alone changes nothing, becausePageResourceLoader.dispatchLoad()falls back toloadFromHostBindings(), so the download just reroutes. AndSourceMapManager.setEnabled(false)cannot be toggled around a symbolication, becausesetEnabled(true)re-attaches every registered client at once.Separately, the uncaught
Unknown sessioncrash I mentioned is now #2466 with a regression test. Unrelated to this, I just kept hitting it while measuring.fix: load source maps on demand instead of for every parsed script
fix: do not throw synchronously when a CDP session is gone (ChromeDev…
yulunz commentedon Aug 4, 2026
Verified source maps served from Jira is bloating the memory because of eager loading, as @Dmitriusan had pointed out. To fix this
we are adding a feature to lazy load the source map in the upstream (link), and I will update the MCP server once that's reflected here.
Separately, there are other sources of memory leak: 1) not properly disposing IsolatedFileSystemManager, and 2) not unregistering handlers in PuppeteerDevToolsConnection. #2465 attempts to fix both but we will abandon that and fill fix those in the upstream instead (link, and more coming).
It seems there are multiple instances of memory leaks / unexpected increase in memory already. We will update the regression tests in scripts/eval_scenarios to be able to better prevent / catch instances like this in the future.
Thanks to everyone who contributed debugging this issue! Please keep the reports coming if you all see anything :)
Add option to lazy load source maps.
chore: add a script to capture memory snapshots (ChromeDevTools#2464)
chore: re-use connection adapter and dispose devtools unvierse (Chrom…
OrKoN commentedon Aug 10, 2026
This should be fixed in 1.7.0.