[Bug] Critical Memory Leak in Claude CLI - Grows to 8.5GB+ During Code Generation
Resolved 💬 4 comments Opened Feb 18, 2026 by Kawaii-Yuki-Kun Closed Feb 22, 2026
Bug Report: Critical Memory Leak in Claude CLI
Summary
Claude CLI experiences a severe memory leak during code generation and codebase analysis tasks, growing from ~560MB to 8.5GB+ in under 10 minutes. Memory continues growing even when idle, eventually causing system-wide swap thrashing and performance degradation.
System Information
- OS: Pop!_OS (Ubuntu-based)
- RAM: 16GB
- Swap: 19GB
- Claude CLI Version: 2.1.44 (Claude Code)
- Installation Method: curl
Reproduction Steps
- Start Claude CLI with system monitoring active
- Execute simple query (e.g., "What's the capital of France?")
- Memory: ~560MB (baseline - normal)
- Request code generation (e.g., "Write a Python script that finds all .txt files in a directory and counts words")
- Memory: Begins climbing
- Ask Claude to analyze a large codebase (e.g., Laravel project)
- Memory: Escalates rapidly to 6.4GB+
- Leave Claude CLI idle (no prompts) for 2 minutes
- Memory: Continues growing to 8.5GB+
Expected Behavior
- Memory usage should stabilize at reasonable levels (500MB-1.5GB)
- Memory should not grow while idle
- Memory should be released after completing tasks
Actual Behavior
- Memory grows continuously: 562MB → 6,464MB → 8,545MB
- Growth continues even when no operations are being performed
- No memory is released until process is killed
- Eventually causes:
- RAM exhaustion (14GB/16GB consumed)
- Heavy swap usage (17GB+ swap)
- System-wide performance degradation (thrashing)
Impact/Severity
CRITICAL - Makes Claude CLI unusable for:
- Code generation tasks
- Large project analysis
- Extended work sessions
- Systems with limited RAM
Without frequent restarts, the leak renders the entire system unresponsive within minutes.
Additional Observations
- Leak triggers:
- Code generation requests
- Large codebase/file analysis
- Multiple consecutive operations
- Memory growth pattern:
- Starts during second prompt
- Escalates rapidly with code/project analysis
- Continues growing autonomously while idle (indicates background process leak)
- Workaround:
- Restart Claude CLI after every major task
- Kill process if memory exceeds 1.5GB
- Avoid large codebase analysis
Monitoring Evidence
Memory progression over ~10 minutes:
Time Memory Task
10:43 562 MB Initial startup
10:53 6,464 MB After code generation + project analysis
10:59 8,545 MB After 2 minutes idle (no prompts)
System impact:
RAM: 13Gi / 16Gi (81% utilization)
Swap: 2Gi active (system thrashing)
Request
Please investigate garbage collection and memory management in Claude CLI, particularly around:
- Code generation operations
- File/project analysis
- Background processes that continue after task completion
---
Environment Info
- Platform: linux
- Terminal: gnome-terminal
- Version: 2.1.44
- Feedback ID: 0c7c3142-6c60-426c-a858-ca2b12a91f8f
Errors
[]This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗