Skip to content

WebView2 process leak on Windows: 25 msedgewebview2 children spawned via Python multiprocessing, ~30 GB RAM #1281

Description

@ptrcao

Summary

On Windows 11, running Serena MCP under Claude Code causes a large number of msedgewebview2.exe subprocesses to be spawned via Python multiprocessing workers. These accumulate without being released, consuming tens of GB of RAM. In my case, 25 Python-spawned WebView2 processes were using 29.33 GB before I killed them.

This appears distinct from closed issue #944 (which was about in-process Python cache memory and fixed via PR#944). Here the memory is consumed by external msedgewebview2.exe child processes spawned transitively from Serena's Python process, each with its own EBWebView user-data-dir in %TEMP%.

Environment

  • OS: Windows 11 Pro, build 10.0.26200
  • Python: 3.11.4 (C:\Users\<user>\AppData\Local\Programs\Python\Python311\python.exe)
  • WebView2 Runtime: 146.0.3856.97 (children use 146.0.3856.84)
  • MCP client: Claude Code (context: claude-code)
  • Install: uvx (via uv cache: C:\Users\<user>\AppData\Local\uv\cache\archive-v0\XiIKL63yuOe4aks2GEraP\Scripts\serena.exe)
  • Launch command: serena.exe start-mcp-server --context claude-code --project-from-cwd

Evidence

Process tree (before kill)

python.exe (PID 62316, Serena root)  ← serena.exe start-mcp-server --context claude-code --project-from-cwd
└── python.exe (PID 56608)  ← multiprocessing.spawn worker (--multiprocessing-fork)
    └── msedgewebview2.exe (PID 57508, root WebView2 host)
        └── msedgewebview2.exe × 24 (render/GPU/utility children)

Root WebView2 host cmdline:

"C:\Program Files (x86)\Microsoft\EdgeWebView\Application\146.0.3856.84\msedgewebview2.exe"
  --embedded-browser-webview=1
  --webview-exe-name=python.exe
  --webview-exe-version=3.11.4
  --user-data-dir="C:\Users\<user>\AppData\Local\Temp\tmp9egdon_4\EBWebView"
  --noerrdialogs
  --embedded-browser-webview-dpi-awareness=1
  --allow-file-access-from-files
  --disable-features=ElasticOverscroll
  --mojo-named-platform-channel-pipe=56608.62956.8454838954105898844
  /pfhostedapp:b591bec3b542afa3c100ae7c5dfb56b2625711eb

The --embedded-browser-webview=1 + --webview-exe-name=python.exe flags indicate a Python library is instantiating a WebView2 control (likely pywebview with EdgeChromium backend, or equivalent). Each multiprocessing worker creates its own fresh WebView2 with a unique tmpXXXX/EBWebView user-data-dir.

Memory accounting

Grouping all msedgewebview2.exe on the system by parent process:

Parent Count Total MB
msedgewebview2 (all Python-spawned) 25 29,866
python 5 207.8
SearchHost 1 62.8
Acrobat 1 22.1
WhatsApp.Root 1 21.8

Resolving the msedgewebview2-parented ones up the tree: all 25 grandparent to python.exe running multiprocessing.spawn which in turn is a child of the Serena root process.

Leaked temp data dirs

%TEMP% contains 13 orphaned tmpXXXX/EBWebView directories — user-data-dirs that were never cleaned up on worker exit.

Reproduction

  1. Windows 11 with Claude Code installed
  2. Serena MCP configured as an MCP server for Claude Code (standard claude-code context, --project-from-cwd)
  3. Use Claude Code normally against a project for some time
  4. Observe msedgewebview2.exe process count and memory growing steadily

I have not yet isolated which Serena code path / dependency is creating the WebView2 instances. The multiprocessing.spawn pattern suggests a worker pool where each worker, on startup, imports a module that instantiates a WebView2 (possibly related to the dashboard, documentation preview, or an LSP/indexing dependency that pulls in pywebview or similar on Windows).

Mitigation (surgical kill)

PowerShell one-liner to kill only Python-spawned WebView2 processes while leaving other apps' WebView2 usage untouched:

Get-Process msedgewebview2 | Where-Object { (Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").CommandLine -like '*webview-exe-name=python*' } | Stop-Process -Force

Confirmed this recovers the full ~30 GB without killing the Serena MCP session or other WebView2-using apps (Outlook, Acrobat, WhatsApp, SearchHost, etc.).

Ask

  • Can maintainers identify which Serena dependency / code path is instantiating WebView2 via a multiprocessing worker pool on Windows?
  • Whatever it is, the user-data-dir cleanup (tmpXXXX/EBWebView) and worker lifecycle clearly aren't releasing the WebView2 subprocesses.
  • Happy to provide logs (~/.serena/logs), run with log_level: debug, or test a fix branch.

Filed with gh — I'm happy to add any further diagnostics on request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions