perf(memory): release old navigation request in NetworkCollector#1200
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
e58c401 to
673f7bc
Compare
673f7bc to
31ae91b
Compare
|
Thank you! Adding the missing
|
31ae91b to
f4813c5
Compare
|
Thanks for the review! I have updated the PR according to your suggestions:
Let me know if anything else is needed! |
f4813c5 to
709f530
Compare
|
Thanks! Just 1 more nit: could you please go back to |
709f530 to
778c04f
Compare
|
Done! Changed |
|
Cool! Now only the test needs fixing. |
778c04f to
5f4af57
Compare
e6f3325 to
de37c18
Compare
|
Done! I've reverted the |
🤖 I have created a release *beep* *boop* --- ## [0.20.3](chrome-devtools-mcp-v0.20.2...chrome-devtools-mcp-v0.20.3) (2026-03-20) ### 🛠️ Fixes * mark categoryExtensions flag mutually exclusive with autoConnect ([#1202](#1202)) ([8c2a7fc](8c2a7fc)), closes [#1072](#1072) ### ⚡ Performance * **memory:** release old navigation request in NetworkCollector ([#1200](#1200)) ([1e6456c](1e6456c)) * use CDP to find open DevTools pages (reland) ([#1210](#1210)) ([53483bc](53483bc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
…omeDevTools#1200) Issue ChromeDevTools#1192 ## Problem In `--autoConnect` mode, `chrome-devtools-mcp` experiences a severe memory leak (~13 MB/min) when Chrome is actively used. This eventually leads to OOM crashes or kernel panics. The root cause is in `src/PageCollector.ts`: 1. `NetworkCollector` overrides `splitAfterNavigation` but forgets to call `navigations.splice(this.#maxNavigationSaved)`, causing the array of navigations to grow infinitely. 2. Even within a single navigation (e.g., in long-lived SPA applications), the `navigations[0]` array grows infinitely because there is no limit on the number of items collected per navigation. Since `HTTPRequest` objects are heavy, this quickly exhausts memory. ## Solution 1. Changed `#maxNavigationSaved` to `protected maxNavigationSaved` so subclasses can access it. 2. Added `navigations.splice(this.maxNavigationSaved)` to `NetworkCollector.splitAfterNavigation` to ensure old navigations are properly discarded. 3. Introduced `protected maxItemsPerNavigation = 5000` to limit the number of items stored per navigation. When the limit is reached, the oldest item is removed (`shift()`), preventing unbounded memory growth in SPAs. Tested locally by running `npm run build` and verifying the fix. --------- Co-authored-by: Wolfgang Beyer <woolfi.b@gmail.com>
🤖 I have created a release *beep* *boop* --- ## [0.20.3](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v0.20.2...chrome-devtools-mcp-v0.20.3) (2026-03-20) ### 🛠️ Fixes * mark categoryExtensions flag mutually exclusive with autoConnect ([ChromeDevTools#1202](ChromeDevTools#1202)) ([8c2a7fc](ChromeDevTools@8c2a7fc)), closes [ChromeDevTools#1072](ChromeDevTools#1072) ### ⚡ Performance * **memory:** release old navigation request in NetworkCollector ([ChromeDevTools#1200](ChromeDevTools#1200)) ([1e6456c](ChromeDevTools@1e6456c)) * use CDP to find open DevTools pages (reland) ([ChromeDevTools#1210](ChromeDevTools#1210)) ([53483bc](ChromeDevTools@53483bc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Issue #1192
Problem
In
--autoConnectmode,chrome-devtools-mcpexperiences a severe memory leak (~13 MB/min) when Chrome is actively used. This eventually leads to OOM crashes or kernel panics.The root cause is in
src/PageCollector.ts:NetworkCollectoroverridessplitAfterNavigationbut forgets to callnavigations.splice(this.#maxNavigationSaved), causing the array of navigations to grow infinitely.navigations[0]array grows infinitely because there is no limit on the number of items collected per navigation. SinceHTTPRequestobjects are heavy, this quickly exhausts memory.Solution
#maxNavigationSavedtoprotected maxNavigationSavedso subclasses can access it.navigations.splice(this.maxNavigationSaved)toNetworkCollector.splitAfterNavigationto ensure old navigations are properly discarded.protected maxItemsPerNavigation = 5000to limit the number of items stored per navigation. When the limit is reached, the oldest item is removed (shift()), preventing unbounded memory growth in SPAs.Tested locally by running
npm run buildand verifying the fix.