Background subagent processes leak to 26+20 GiB (mostly compressor pages), freezing a 16 GB Mac until forced restart

Status Open
Reported on v2.1.222
Maintainer reply None cached
Activity 1 comment · opened Aug 8, 2026

Summary

Two background-subagent claude worker processes leaked memory over ~40 minutes — reaching 26.4 GiB and 20.3 GiB physical footprint (mostly compressed pages) on a 16 GiB MacBook Pro — until macOS jetsam started killing system daemons wholesale and the machine froze completely, requiring a forced restart (which itself produced a shutdownStall report).

The subagents' transcripts are small (300–600 KB, no single tool result over 34 KB), so this does not look like context/transcript accumulation — it looks like a process-level leak in long-running background agents. The footprint being almost entirely compressor pages (highly compressible) suggests leaked/retained text buffers, e.g. accumulated Bash/WebFetch output that is no longer reachable from the conversation context.

Environment

  • Claude Code 2.1.222 (bundled in the Claude desktop app, local agent mode); CLI now at 2.1.224
  • macOS 26.5.2 (25F84), MacBookPro18,1 (M1 Pro), 16 GB RAM
  • Session: a long-running research session using the Agent tool with run_in_background fan-out

What the session was doing

The session fanned out ~10 concurrent background subagents (general-purpose type) between T+0 and T+11 min:

  • 8 web-research agents (many Bash curl calls + WebSearch/WebFetch, 34–82 tool calls each, running 40+ minutes)
  • 1 audit agent that spawned nested subagents of its own
  • 4 short-lived batch classification agents (these finished fine)

Timeline (local time, from the desktop app's [process-memory] log and the JetsamEvent report)

| Time | Event |
|---|---|
| 09:39–09:50 | Background subagents spawned |
| 09:52 | Worker pid 41650 already at ~1.0 GB RSS; app logs [CliGovernor] memory pressure (warning): would evict 0 idle session(s), 1 effective repeatedly from here on |
| 10:01 | Last desktop-app log line for 44 minutes — app starved |
| 10:21 | Main session's trivial Bash call (append to a state file) hangs for 10 minutes |
| 10:31 | JetsamEvent: pids 41650 / 43179 at 26.4 / 20.3 GiB footprint; dozens of system daemons jettisoned; snapshot contains 4,000 process entries incl. 216 × cfprefsd (respawn storm) |
| 10:43 | Forced restart; shutdownStall report written |

Evidence excerpts

JetsamEvent (bug_type 298, largestProcess = claude) process entries:

{'name': 'claude', 'pid': 41650, 'rpages': 1731988, 'lifetimeMax': 1731988,
 'physicalPages': {'internal': [67790, 1663332]}, 'priority': 180, 'fds': 25,
 'cpuTime': 348.0, 'states': ['active']}   # 1,731,988 × 16 KiB pages = 26.4 GiB
{'name': 'claude', 'pid': 43179, 'rpages': 1329175, 'lifetimeMax': 1329175,
 'physicalPages': {'internal': [41237, 1287272]}, 'priority': 180, 'fds': 25,
 'cpuTime': 325.4, 'states': ['active']}   # 20.3 GiB

Note internal: [uncompressed, compressed] — ~96% of both footprints is in the compressor.

Desktop app main.log (both pids are descendants of the session's claude process):

09:52:05 [process-memory] tree_rss_sum=2821MB ... top=[descendant:41650:1001MB ...]
09:54:03 [process-memory] tree_rss_sum=3250MB ... top=[descendant:41650:1095MB ... descendant:43179:361MB ...]
10:01:05 [process-memory] ... sys_free=1734MB/16384MB
(no further log lines until 10:45, after reboot)

Impact

Complete system freeze: jetsam killed WindowServer helpers, secd, cloudd, homed, photolibraryd, etc. in a loop while the two leaking processes survived at priority 180. The machine was unrecoverable without a forced power-off, and the forced shutdown stalled.

Two smaller observations from the same session that may be related:

  1. The high-priority jetsam band means runaway claude workers outlive the system daemons the UI needs — a per-process memory ceiling (or lower jetsam priority for subagent workers) would have contained this.
  2. The desktop app's CliGovernor saw the pressure for 40 minutes but "would evict 0 idle session(s)" — it has no lever against an active session's runaway descendants.

Artifacts available on request

  • JetsamEvent-2026-08-08-103131.ips (2.4 MB, full process list — happy to share privately)
  • shutdown_stall_2026-08-08-104326_m21.shutdownStall
  • Desktop app main.log excerpts, session + subagent transcripts

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗