[BUG] Scheduled-task / background worker processes not reaped, accumulate until macOS runs out of memory
Bug
Background worker processes spawned by scheduled tasks (and other background sessions) are not reaped after their work finishes. They accumulate over days under the parent Claude process, driving total resident memory into the tens of GB until macOS throws "Your system has run out of application memory."
This appears related to #60116 (child not terminated on --resume), but the trigger here is the scheduled-task / background-session runner rather than interactive --resume.
Environment
- Claude Code 2.1.181 (running inside the Claude desktop app on macOS)
- macOS, Darwin 25.5.0
- ~19 scheduled tasks configured, several firing every 15-30 min
Evidence
Live process snapshot on an affected machine:
- 102
claude-code/2.1.181/claudeprocesses running concurrently, all parented to the single Claude app process (none orphaned/reparented to launchd). - They spawn in pairs: a 0 MB launcher + a ~90 MB worker.
- Oldest survivors are 3+ days old (
etime03-06:30:50), long past when their task should have completed. - These processes alone account for ~4.6 GB RSS and climb the longer the app stays open.
- macOS attributes all children to the responsible app, so the Force Quit dialog reports "Claude" at 20+ GB.
Process-age sample (oldest first), showing launcher/worker pairs that never exit:
03-06:30:50 worker ~91MB
03-06:09:15 worker ~88MB
03-05:44:30 worker ~88MB
...
02-16:03:13 worker ~90MB
01-16:16:32 worker ~92MB
Expected
Each scheduled-task / background worker process should exit once its run completes. Process count should stay roughly proportional to currently-running tasks, not grow unbounded with each cron firing.
Actual
Finished workers stay alive indefinitely, parented to the app, and accumulate across days until the machine runs out of memory (occurs once or twice a day on a heavy scheduled-task setup).
Workaround
Quitting and relaunching the Claude app kills the stragglers and drops memory back to a few hundred MB.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗