Exit code 9 crash during concurrent Opus streaming — likely #19378 memory leak

Resolved 💬 3 comments Opened Feb 16, 2026 by shayesdevel Closed Feb 19, 2026

Description

Claude Code process crashed with exit code 9 during concurrent multi-agent operation. Three parallel Task agents (all Opus model with extended thinking) were streaming API responses simultaneously when the process terminated.

Root Cause

This appears to be a manifestation of #19378 — the unbounded memory leak during API response streaming.

The streaming response handler fails to free response chunks incrementally. With 3 concurrent Opus agents all streaming extended thinking responses simultaneously, memory growth of ~1GB/second per stream would compound to ~3GB/second, exhausting all available memory within seconds of all streams activating.

Exit code 9 is produced when the Bun runtime (JavaScriptCore engine) encounters a fatal memory allocation failure during this unbounded growth.

Environment

  • Claude Code: v2.1.42 (native binary, Bun/JSC runtime)
  • Model: Opus 4.6 (Claude Max)
  • OS: WSL2 (Linux 6.6.87.2-microsoft-standard-WSL2) on Ubuntu
  • WSL2 config: 12GB RAM, 8 processors, 16GB swap

Steps to Reproduce

  1. Start Claude Code session
  2. Dispatch 3+ concurrent Task agents using Opus model (extended thinking)
  3. Wait for all agents to begin streaming API responses simultaneously (~2-3 minutes)
  4. Process terminates with exit code 9 as memory grows unboundedly

What Happened

  • Session started normally, nexus-wake skill completed
  • 3 Task agents (type: Explore, model: opus) dispatched concurrently
  • At ~3 minutes, all agents were actively streaming — process terminated with exit code 9
  • No subagent completed — all 3 were mid-execution when killed
  • No graceful shutdown, no error message, no crash dump
  • Terminal showed: [process exited with code 9 (0x00000009)]

Connection to #19378

Issue #19378 documents this exact memory leak pattern:

  • Reported on v2.1.12, confirmed on v2.1.25, still open with no fix on v2.1.42
  • Growth rate: ~1GB/second per streaming response
  • With 3 concurrent streams: ~3GB/second compound growth
  • Users on 128GB systems report ballooning to 90GB before Aborted() crash
  • On our 12GB WSL2 system, this exhausts all memory in seconds once all streams activate

The key differentiator is concurrent Opus streaming — running agents sequentially or with lighter models avoids compound memory growth.

Expected Behavior

  • Streaming response handler should process and free chunks incrementally
  • Memory should remain bounded during API response streaming
  • At minimum, detect approaching memory limits and gracefully terminate subagents

Session Forensics

Session 884b4dc0:

  • 3 Task agents spawned between 03:34:57 and 03:35:05 UTC
  • Last progress entry at 03:37:05 UTC
  • 93-second gap before session restart
  • 0 of 3 subagents completed

Related Issues

  • #19378 — Memory leak during API response streaming (root cause, OPEN)
  • #7020 — Memory leak when initializing sub-agent orchestration
  • #14052 — Memory leak with custom orchestrator agent consuming 15+ GB
  • #15262 — Deeper subagent calls trigger OOM
  • #1421 — Recurring crashes: JavaScript Heap Out of Memory while 'thinking'

View original on GitHub ↗

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