Claude Code CLI triggers macOS kernel memory leak (kalloc.1024) → kernel panic

Resolved 💬 3 comments Opened Apr 7, 2026 by stereome Closed Apr 11, 2026

Summary

Claude Code CLI triggers a kernel-level memory leak in macOS kalloc.1024 zone at ~30-48 MB/min, exhausting 16 GB RAM and causing kernel panic (WindowServer watchdog timeout) within 4-6 hours of use. The leak occurs in any terminal emulator (iTerm2, Terminal.app) and stops immediately when Claude Code process is terminated.

Environment

  • macOS: 15.7.5 (Sequoia), also reproduced on 15.7.4
  • Hardware: MacBook Pro M1 Pro, 16 GB RAM
  • Claude Code: 2.1.92 (also observed on earlier versions)
  • Terminals tested: iTerm2 (Metal ON and OFF), Terminal.app
  • Node: bundled with Claude Code

Reproduction

  1. Reboot Mac (clean state, kalloc.1024 < 200 MB)
  2. Launch Claude Code CLI in any terminal
  3. Monitor kalloc.1024 zone: sudo zprint | awk '/data\.kalloc\.1024/ {print $3}'
  4. Observe ~30-48 MB/min growth in kernel memory
  5. After 4-6 hours: kalloc.1024 reaches 11-14 GB → WindowServer watchdog timeout → kernel panic

Evidence: Controlled Experiments (April 7, 2026)

Experiment 1: Claude Code ON vs OFF (definitive)

| Conditions | kalloc.1024 Δ/min | Result |
|---|---|---|
| iTerm + Metal ON + Claude Code | ~30 MB/min | Leaking |
| iTerm + Metal OFF + Claude Code | ~36 MB/min | Metal is NOT the cause |
| Terminal.app + Claude Code | ~42 MB/min | iTerm is NOT the cause |
| Terminal.app + Claude Code, all other apps closed | ~44 MB/min | Other apps NOT the cause |
| Terminal minimized, Claude Code idle | ~27 MB/min | Still leaking even idle |
| macOS Safe Mode + Claude Code | Leaking | kext NOT the cause |
| No terminal with Claude Code running | 0 MB/min | CONFIRMED: Claude Code is the trigger |

Experiment 2: 5-minute OFF/ON cycle (timestamped CSV log)

Claude Code running (22:18–22:42):

22:18  kalloc.1024 = 1675 MB
22:30  kalloc.1024 = 2144 MB  (+42 MB/min)
22:42  kalloc.1024 = 2646 MB  (+42 MB/min)

Claude Code killed (~22:43):

22:43  kalloc.1024 = 2660 MB  (inertia)
22:44  kalloc.1024 = 2660 MB  (0 MB/min) ← STOPPED
22:45  kalloc.1024 = 2660 MB  (0 MB/min)
22:46  kalloc.1024 = 2660 MB  (0 MB/min)
22:47  kalloc.1024 = 2660 MB  (0 MB/min)

4 consecutive minutes of zero growth after killing Claude Code.

Kernel panic logs

Two kernel panics with identical signature:

panic: userspace watchdog timeout: no successful checkins from WindowServer in 120 seconds
Zone info: data.kalloc.1024  11G  (April 5)
Zone info: data.kalloc.1024  13G  (April 7)

Full panic logs available at:

  • /Library/Logs/DiagnosticReports/panic-full-2026-04-07-095644.0002.panic
  • /Library/Logs/DiagnosticReports/panic-full-2026-04-05-101144.0002.panic

Hypothesis: Root Cause

Claude Code's Ink/React-based TUI generates a high-frequency stream of terminal redraws. Each redraw triggers kernel allocations through the GPU compositor pipeline:

Claude Code (Node/Ink) → terminal escape sequences → Terminal.app/iTerm 
→ WindowServer → AGXG13X (Apple GPU driver) → kalloc.1024 allocations

The allocations in kalloc.1024 are never freed — this is a kernel-side bug (likely in Apple's GPU driver or WindowServer), but Claude Code is the only known application that triggers it at this rate due to its TUI rendering pattern.

Related Issues

  • #32752 — Native addon memory leak (~18 GB/hour), node-pty suspected
  • #11315 — 129 GB RAM consumed, system freeze
  • #23252 — 12 GB on macOS 15.5
  • #27421 — Sessions killed in 8 min (v2.1.49)
  • #33673 — Recent CLI memory leak
  • ghostty-org/ghostty#10289 — Ghostty found and fixed their side of the terminal leak triggered by Claude Code's multi-codepoint output (fix in Ghostty 1.3)

Possible Mitigations

On Claude Code side:

  • Reduce TUI redraw frequency (throttle Ink render cycles)
  • Batch terminal escape sequence output
  • Offer a "low-rendering" or "plain text" mode for long sessions
  • Investigate if node-pty buffer handling contributes to kernel allocations

Workarounds (user side):

  • Reboot every 3-4 hours when using Claude Code
  • Use Claude Code via SSH to a remote machine
  • Use claude.ai web interface instead of CLI
  • Monitor kalloc.1024 and reboot when > 8 GB

Monitoring Script

CSV logger that tracks kalloc.1024 every 60 seconds (used for the data above):

# One-liner to check current kalloc.1024
sudo zprint | awk '/data\.kalloc\.1024/ {print $3}' | head -1

Full monitoring script and CSV data available on request.

View original on GitHub ↗

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