[BUG] Memory leak: API clients created repeatedly instead of reused (8-9 GB memory usage)
Resolved 💬 5 comments Opened Jan 31, 2026 by GobindB Closed Mar 25, 2026
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?
Description:
Claude Code is consuming excessive memory (8-9 GB) due to what appears to be an API client leak. Debug logs show 114 API clients being created in a short session, with bursts of 24-28 clients created per second.
Environment:
- Claude Code version: 2.1.27
- OS: macOS Darwin 24.3.0
- Installation: Homebrew cask (/opt/homebrew/Caskroom/claude-code/2.1.27/claude)
Symptoms:
- Single claude process using 8-9 GB RAM (25% of system memory)
- Memory grows quickly even with minimal conversation
What Should Happen?
Expected behavior:
- no OOM events
- API clients should be reused rather than recreated, and memory usage should stay reasonable (< 1 GB for typical sessions).
Error Messages/Logs
Evidence from debug logs:
# 114 total API clients created
$ grep -c "Creating client" ~/.claude/debug/latest
114
# Bursts of client creation (clients created per second):
28 12:53:52
24 12:55:27
24 12:54:38
24 12:54:28
Example of 17 clients created in the same millisecond:
2026-01-31T12:55:27.714Z [DEBUG] [API:request] Creating client...
2026-01-31T12:55:27.714Z [DEBUG] [API:request] Creating client...
(repeated 17 times)
Steps to Reproduce
Steps to reproduce:
- Start Claude Code
- Have a brief conversation
- Monitor memory with Activity Monitor or ps aux
- Check ~/.claude/debug/latest for client creation count
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.27
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗