You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance) #17391
When closing iTerm2 (and likely other terminals) without explicitly exiting Claude Code first, the node processes become orphaned instead of terminating. These orphaned processes then experience runaway memory consumption, each ballooning to ~34GB of V8 heap before crashing with OOM.
Environment
OS: macOS 15.5 (24F74)
Architecture: ARM64 (Mac16,13 - MacBook Air)
Terminal: iTerm2
Reproduction
Open multiple iTerm2 windows/tabs with Claude Code sessions running
Close iTerm2 (Cmd+Q or close windows) without explicitly exiting Claude Code
Observe orphaned node processes consuming increasing amounts of RAM
Eventually each process crashes with V8 OOM at ~34GB
In one incident, 8+ Claude Code instances went to ~4GB each simultaneously before crashing, causing system-wide memory pressure and requiring a restart.
A separate incident spawned 10 rapid-fire subagent processes that all crashed with OOM within 30 seconds.
Expected Behavior
Claude Code should:
Properly handle SIGHUP signal when terminal closes
Terminate gracefully instead of becoming an orphan
Not experience runaway memory allocation if orphaned
Workaround
Explicitly exit Claude Code before closing terminal windows:
Ctrl+C to interrupt
Or type /exit
Reacted by Paul Berg, Ben Adrian Sarmiento, Alex Ezzeddine, Joo Won Lee, kylesnowschwartz, khmob and dmd1214GH
Found another way to trigger orphaned processes: context limit reached (without terminal close or /exit).
See #18981 — when the context percentage mismatch bug (#18241) causes premature "Context limit reached", background agents aren't cleaned up. Same symptom (orphaned process at 100%+ CPU), different trigger.
This suggests the cleanup mechanism may need to listen for multiple session-end signals, not just terminal/exit events.
Experiencing the same issue on macOS with iTerm2 and PyCharm integrated terminal.
Observed behavior
After closing terminals without explicitly exiting Claude Code, found 22+ orphan processes accumulated over several days:
username 63707 100.2 10.1 515016720 3397904 ?? R Fri07AM 43:07.66 claude
username 63462 10.2 0.6 509344192 204832 ?? S Fri07AM 69:49.41 claude
username 73132 7.8 0.6 510144016 196144 ?? S Fri09AM 59:50.86 claude
... (20+ more processes dating back several days)
Top process using 100% CPU and 3.4GB memory
Processes from Thursday and Friday still running on Saturday
Combined memory usage was several GB
Environment
macOS Darwin 25.2.0
iTerm2 + PyCharm terminal
preferredNotifChannel: "iterm2_with_bell"
Workaround
I created a simple cleanup tool for macOS users:
👉 claude-code-cleanup - Double-click to run, shows running processes, and kills orphaned ones.
Or use terminal:
# Kill all orphan Claude processes
pkill -9 claude
Prevention
Until this is fixed, exit Claude Code properly before closing terminal:
Additional reproduction case: Subagents not terminated on Ctrl+C
Environment
OS: macOS 15.3.1 (Darwin 25.2.0)
Terminal: iTerm2
Claude Code: 2.1.x
Observation
Even when explicitly terminating Claude Code with Ctrl+C, subagent processes (spawned via the Task tool) are not terminated and become orphaned.
In my case, I found 154 orphaned Claude Code processes after several sessions were closed with Ctrl+C over the course of a day.
$ ps aux | grep -c "/Users/.../.local/bin/claude"
154
Breakdown:
~120 processes with --output-format stream-json flags (subagents)
~30 main session remnants
System Impact
Load Average: 140+ (normal: ~8)
CPU idle: 0.6%
Memory: 15GB used, only 76MB free
Compressor: 7.8GB (heavy swapping)
Root Cause
The issue appears to be that SIGINT (Ctrl+C) is not propagated to child processes spawned by the Task tool. When the parent process terminates, these subagents become orphaned instead of being cleaned up.
Suggested Fix
Register signal handlers in the main process to forward SIGINT/SIGTERM/SIGHUP to all child processes
Use process groups (setpgid) so the entire process tree can be terminated together
Implement cleanup logic in the main process that tracks and terminates spawned subagents on exit
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Jan 10, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
gabrielbryk commentedon Jan 13, 2026
Having same issue
maxim-uvarov commentedon Jan 17, 2026
I have orphaned processes in zellij inside of wezterm. #18752
smconner commentedon Jan 18, 2026
🔗 Related: New trigger scenario
Found another way to trigger orphaned processes: context limit reached (without terminal close or
/exit).See #18981 — when the context percentage mismatch bug (#18241) causes premature "Context limit reached", background agents aren't cleaned up. Same symptom (orphaned process at 100%+ CPU), different trigger.
This suggests the cleanup mechanism may need to listen for multiple session-end signals, not just terminal/exit events.
PaulRBerg commentedon Jan 18, 2026
Also encountering this. It started happening after a recent update.
yowmamasita commentedon Jan 18, 2026
workaround for macos https://gist.github.com/yowmamasita/f3458e89367a82fbdee4366f456ed576
AlexEzzeddine commentedon Jan 19, 2026
Also happening for me. When I close terminal tab, I expect claude code process to be killed
danneu commentedon Jan 20, 2026
I came to report the same issue.
I think it's a new regression in the native build since I think I would have noticed it weeks ago otherwise.
It should exit on sighup.
PaulRBerg commentedon Jan 20, 2026
@danneu it also happens with the npm build
Joowonoil commentedon Jan 24, 2026
Additional case report
Experiencing the same issue on macOS with iTerm2 and PyCharm integrated terminal.
Observed behavior
After closing terminals without explicitly exiting Claude Code, found 22+ orphan processes accumulated over several days:
Environment
preferredNotifChannel: "iterm2_with_bell"Workaround
I created a simple cleanup tool for macOS users:
👉 claude-code-cleanup - Double-click to run, shows running processes, and kills orphaned ones.
Or use terminal:
# Kill all orphan Claude processes pkill -9 claudePrevention
Until this is fixed, exit Claude Code properly before closing terminal:
/exitCtrl+CthenCtrl+D+1 for implementing proper SIGHUP handling.
Joowonoil commentedon Jan 24, 2026
Update: This issue appears to be fixed in v2.1.19.
I was on v2.1.15 and upgraded via
brew upgrade claude. After the update, orphan processes no longer seem to persist when closing the terminal.Can others confirm?
PaulRBerg commentedon Jan 24, 2026
yeah it's fixed in v2.1.19
jikuya commentedon Jan 30, 2026
Additional reproduction case: Subagents not terminated on Ctrl+C
Environment
Observation
Even when explicitly terminating Claude Code with
Ctrl+C, subagent processes (spawned via theTasktool) are not terminated and become orphaned.In my case, I found 154 orphaned Claude Code processes after several sessions were closed with
Ctrl+Cover the course of a day.Breakdown:
--output-format stream-jsonflags (subagents)System Impact
Root Cause
The issue appears to be that
SIGINT(Ctrl+C) is not propagated to child processes spawned by theTasktool. When the parent process terminates, these subagents become orphaned instead of being cleaned up.Suggested Fix
SIGINT/SIGTERM/SIGHUPto all child processessetpgid) so the entire process tree can be terminated togetherWorkaround
Manual cleanup of orphaned processes:
pkill -f "claude.*stream-json"Or periodic monitoring:
github-actions commentedon Feb 28, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Mar 8, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.