Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance)

Resolved 💬 15 comments Opened Jan 10, 2026 by thomascassidyzm Closed Feb 28, 2026

Description

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

  1. Open multiple iTerm2 windows/tabs with Claude Code sessions running
  2. Close iTerm2 (Cmd+Q or close windows) without explicitly exiting Claude Code
  3. Observe orphaned node processes consuming increasing amounts of RAM
  4. Eventually each process crashes with V8 OOM at ~34GB

Evidence from Crash Reports

Crash 1 (orphaned)

"pid" : 52713
"parentProc" : "Exited process"
Memory Tag 255: 34.3G (16,444 regions)

Crash 2 (orphaned)

"pid" : 40417
"parentProc" : "Exited process"  
Memory Tag 255: 34.3G (16,424 regions)

Stack trace shows V8 OOM:

node::OOMErrorHandler
  → v8::internal::V8::FatalProcessOutOfMemory
    → v8::internal::Heap::FatalProcessOutOfMemory
      → v8::internal::Heap::CollectGarbage

Impact

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:

  1. Properly handle SIGHUP signal when terminal closes
  2. Terminate gracefully instead of becoming an orphan
  3. Not experience runaway memory allocation if orphaned

Workaround

Explicitly exit Claude Code before closing terminal windows:

  • Ctrl+C to interrupt
  • Or type /exit

View original on GitHub ↗

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