[BUG] Claude Desktop (Windows) leaks CLI child processes on session switch/resume — unbounded memory growth

Resolved 💬 3 comments Opened May 1, 2026 by bibyhs-design Closed May 4, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When a new CLI process is spawned for a session (especially --resume with the same UUID), the previous CLI process for that session should be terminated. CLI processes for completed scheduled tasks should also be cleaned up after execution.

What Should Happen?

When a user switches sessions or resumes a session in Claude Desktop, the previous CLI child process for that session should be terminated before spawning a new one. Specifically:

  1. Session switch/resume: If a --resume <UUID> CLI process already exists for a given UUID, the old process should be killed before spawning a new one
  2. Scheduled tasks: CLI processes spawned for scheduled task execution should be cleaned up after the task completes
  3. General lifecycle: Claude Desktop should track its spawned CLI children and terminate them when they are no longer needed

This would prevent unbounded memory growth from orphaned CLI processes.

Error Messages/Logs

Steps to Reproduce

  1. Open Claude Desktop on Windows
  2. Start a conversation that triggers Agent Mode (e.g., ask Claude to edit a file) — this spawns a CLI child process (claude.exe with --resume <UUID>)
  3. Switch to a different conversation or resume the same session — a new CLI process is spawned, but the old one is not terminated
  4. Repeat steps 2-3 multiple times over several hours
  5. Open Task Manager or run Get-CimInstance Win32_Process -Filter "Name='claude.exe'" in PowerShell

Observed: Each session switch/resume accumulates another claude.exe process. After ~12 hours of normal use, 50+ orphaned CLI processes consuming 10-13 GB RAM.

Evidence from my system (2026-05-01):

  • 54 claude.exe processes found, only ~15 were active
  • Same session UUID (ce1e885d-...) had 3 separate CLI processes running simultaneously
  • Total memory usage: ~13 GB (54 × ~200-250 MB each)

Additional trigger: Scheduled tasks executed via Claude Desktop's Agent Mode also leave orphaned CLI processes after completion.

Environment:

  • Windows 11 Pro (10.0.26200)
  • Claude Desktop (latest, installed via Microsoft Store)
  • Running for ~18 hours with moderate session switching

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.121 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

text: Workaround: We built a PowerShell cleanup script that runs every 2 hours via Windows Task Scheduler. It identifies zombie CLI processes by checking jsonl session file modification times and kills processes whose sessions have been inactive for 120+ minutes, while preserving Desktop UI processes and active sessions.

Key observations:

  • Each claude.exe CLI process consumes ~200-250 MB RAM
  • After 12-18 hours of normal use, 40-50+ zombie processes accumulate (8-13 GB wasted)
  • The root cause appears to be in Claude Desktop's process lifecycle management — it spawns CLI children but never cleans them up on session switch, resume, or completion
  • The --resume <UUID> flag in the command line allows identification of which session a process belongs to
  • Multiple CLI processes can exist for the same session UUID, confirming that new processes are spawned without killing old ones

{
"format": "text",
"length": 898
}

View original on GitHub ↗

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