[BUG] Subagent grep outlives its session, ate 11 GB of RAM
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
A previous Claude Code session spawned a grep that kept running after the session ended. Found it casually using 38.8% of my RAM (11.4 GB on a 28 GB machine) and 99.9% CPU:
grep -o .\{0,2000\}Your order has been processed.\{0,3000\} ~/.claude/projects/<project>/<session>.jsonl
It was grepping through its own conversation transcript with a huge regex context window, which made it buffer the whole file into memory. Only found it because RAM hit 92% and I went hunting with ps aux.
Child processes from subagents should get cleaned up when the session ends.
Claude Code VS Code extension v2.1.63, Linux
What Should Happen?
Child processes from subagents should get cleaned up when the session ends.
Error Messages/Logs
Steps to Reproduce
- Use Claude Code in VS Code with subagents over a long session
- End the session
- Check
ps aux --sort=-%mem— orphaned grep process still running on the session's JSONL transcript - Process consumes unbounded RAM (11.4 GB in this case)
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.62 (Claude Code) / Extension 2.1.63
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗