Kill bash session ('k' hotkey) triggers runaway spawn loop, 10+ GB memory consumption

Resolved 💬 3 comments Opened Mar 19, 2026 by plac9 Closed Mar 19, 2026

Bug Report

Version: Claude Code 2.1.79 (arm64, macOS 26.4 beta 25E5207k)
Machine: Mac14,9 (M2 Pro), 16 GB RAM

Description

Using Claude Code's built-in bash session manager to kill (k) a listed bash session causes Claude Code to enter a tight main-thread loop of process spawning and socket creation, consuming 10+ GB of RAM and freezing the terminal completely.

This is not killing a running bash command mid-execution — this is using CC's own session/process management UI (the list of tracked bash sessions) and pressing k to terminate one.

Steps to Reproduce

  1. Start a Claude Code session in iTerm2
  2. Have CC execute bash commands (creating tracked bash sessions)
  3. Open CC's bash session list
  4. Select a session and press k to kill it
  5. Terminal becomes completely unresponsive

Evidence from sysdiagnose

Claude Code process (PID 1927, com.anthropic.claude-code):

  • Physical footprint: 10.56 GB (normal: ~800 MB)
  • Peak footprint: 10.7 GB
  • CPU time in 10s sample: 9.25 seconds (94.4 billion instructions)
  • 35 threads, main thread consuming nearly all CPU

Main thread call pattern (from sample -highcpu):
The main thread was in a tight loop performing:

  • posix_spawn (spawning child processes)
  • socketpair (creating IPC socket pairs)
  • setsockopt / fcntl (configuring sockets)
  • open (file I/O)

This appears to be runaway subprocess spawning or cleanup/reconnect logic triggered by the session kill action.

System impact:

  • vm_stat shows heavy compression churn (~6.4M decompressions) and swap activity (142K swapouts)
  • iTerm2 itself was healthy (438 MB, mostly idle) but became unresponsive due to system-wide memory starvation on a 16 GB machine
  • macOS memory pressure forced page compression and swapping across all processes

Expected Behavior

Killing a bash session from CC's session manager should cleanly terminate the subprocess and return to the Claude Code prompt without excessive resource consumption.

Workaround

If terminal freezes after killing a session, force-quit Claude Code (kill -9 <pid> from another terminal) — iTerm2 recovers immediately.

Diagnostic Files

Full sysdiagnose and spindump captured at the time of the incident are available on request.

🤖 Generated with Claude Code

View original on GitHub ↗

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