Subagents spawn duplicate MCP server processes, multiplying kernel resource consumption

Resolved 💬 2 comments Opened Apr 15, 2026 by JF10R Closed May 6, 2026

Summary

Each subagent spawned by Claude Code runs as a separate claude.exe process that independently spawns its own set of MCP server child processes. With N concurrent sessions and M configured MCP servers, this creates N×M child processes, each with 3 stdio pipes (kernel objects), plus duplicated file watchers and memory allocations.

Problem

When Claude Code spawns subagents (via the Agent tool), each subagent:

  1. Starts as a new claude.exe process
  2. Spawns its own MCP server child processes (StdioClientTransport)
  3. Creates its own set of chokidar file watchers
  4. Maintains its own message buffers and caches

For a typical setup with 5 configured MCP servers:

| Scenario | claude.exe | MCP child procs | stdio pipes | chokidar watchers |
|---|---|---|---|---|
| 1 session | 1 | 5 | 15 | 8 |
| 1 session + 2 subagents | 3 | 15 | 45 | 24 |
| 3 sessions + 2 subagents each | 9 | 45 | 135 | 72 |

Each pipe is a kernel object consuming Non-Paged Pool. Each watcher set creates thousands of ReadDirectoryChangesW handles (see #48648).

Observed Impact

On a Windows 11 system with 64 GB RAM, 3 concurrent claude.exe instances (main + subagents) were observed with:

  • Combined private memory: ~15 GB
  • Non-Paged Pool: 35 GB (normal: few hundred MB)
  • System crash: DWM STATUS_NO_MEMORY (0xc00001ad)

Suggested Improvements

  1. Share MCP server connections: Subagents could connect to parent's MCP servers via IPC rather than spawning their own
  2. Lazy MCP startup: Only spawn MCP servers when a tool from that server is actually called
  3. MCP server pooling: Maintain a process-level pool of MCP server connections shared across all agents
  4. Watcher deduplication: Share file watchers across the process tree

Environment

  • claude.exe v2.1.109 (Bun binary)
  • Windows 11 Pro 10.0.26200, 64 GB RAM

Related Issues

  • #42169 (resource exhaustion with multiple claude.exe processes)
  • #48648 (chokidar watcher NPP exhaustion)
  • #20369 (orphaned subagent processes)
  • #48647 (Buffer.slice retention per MCP connection)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗