[BUG] Memory leak: 17GB RSS from accumulated "Tool not found" errors
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 Claude Code session consumed 17 GB of RAM. The process accumulated 22,110 "Tool TodoWrite not found" errors over 36 minutes, each with a full stack trace retained in memory.
What Should Happen?
Memory usage should remain stable when a tool call fails. Error objects should be garbage collected, not accumulated indefinitely.
Error Messages/Logs
Memory profile (vmmap):
WebKit Malloc 22.5G virtual 12.0G resident
Physical footprint (peak): 13.9G
Debug log analysis:
$ grep -c "Tool TodoWrite not found" ~/.claude/debug/<session>.txt
22110
22,110 identical errors generated over ~36 minutes (~10/second):
2026-01-23T19:20:40.560Z [ERROR] Error: Error: Tool TodoWrite not found
at wGB (/$bunfs/root/claude:2316:6809)
at R$ (/$bunfs/root/claude:542:20764)
at Vq (/$bunfs/root/claude:542:39157)
...
Each error includes a full stack trace. If Error objects + stacks average 500KB each, 22,110 errors ≈ 11 GB.
Session timeline:
- Session directory created: Jan 22
- Session started/resumed: Jan 23 04:37
- TodoWrite errors began: Jan 23 19:20
- Process RSS at discovery: ~17 GB (27% of system memory)
Steps to Reproduce
Uncertain. Possibly triggered by resuming a conversation created before the TodoWrite → TaskCreate/TaskUpdate tool rename, where old tool_use blocks in the transcript cause the model to call a tool that no longer exists.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.17
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
If I had to guess, this looks like three separate bugs, but since it's a single failure mode, I'm going to speculate about the chain of events:
- Model calling wrong tool - This is annoying but recoverable.
- App not handling it properly - There exists a state in which the app will enter an internal retry loop without mediation from the model and/or user.
- Errors growing unbounded - This is the critical failure. The app should be able to handle 22,000 errors without consuming 17GB of RAM. Whether the error is "tool not found" or any other error, the memory footprint shouldn't scale linearly with error count.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗