[BUG] Memory leak loop: ~2GB/minute RAM growth even when idle

Resolved 💬 3 comments Opened Jan 29, 2026 by Noammandelbaum Closed Jan 29, 2026

Bug Description

Claude Code has a continuous memory leak that causes RAM usage to grow at approximately 2GB per minute, even when completely idle. This makes the application unusable within minutes.

Evidence - Real-time Memory Growth

Measured over 10 seconds with no user interaction:

Time 0s:  2,358 MB
Time 2s:  2,392 MB  (+34 MB)
Time 4s:  2,505 MB  (+113 MB)
Time 6s:  2,622 MB  (+117 MB)
Time 8s:  2,709 MB  (+86 MB)

Rate: ~350MB in 10 seconds = ~2GB/minute

Process Stats

CPU:             90.2% (while idle!)
RAM:             1.2GB → 2.7GB in 10 seconds
Virtual Memory:  75GB

Environment

  • Claude Code Version: 2.1.19 (also reproduced on 2.1.22)
  • OS: Ubuntu 24.04.3 LTS (Noble Numbat)
  • Kernel: 6.14.0-37-generic x86_64
  • RAM: 32GB total
  • MCP Plugins: Playwright MCP

Reproduction Steps

  1. Start Claude Code (claude)
  2. Have a brief conversation (a few messages)
  3. Monitor memory: watch -n 2 'ps -C claude -o pid,rss,vsz --no-headers | awk "{print \"RAM: \" \$2/1024 \"MB\"}"'
  4. Observe RAM growing continuously even without any interaction

Impact

  • Application becomes unusable within 4-5 minutes on systems with limited RAM
  • System freezes when RAM is exhausted
  • User has tried reinstalling multiple times - helps temporarily but issue returns
  • Requires setting MemoryMax=5G via systemd to prevent full system crash

Related Issues

This appears related to:

  • #18280 (Memory allocation thrashing in main event loop - 16ms timer)
  • #21378 (Unbounded cache growth)
  • #20777 (Memory leak on Linux)

The 90% CPU usage while idle matches the event loop thrashing described in #18280.

Workaround

Currently using systemd memory limit to prevent system crash:

systemd-run --user --scope -p MemoryMax=5G claude

This is not a solution - it just kills Claude instead of freezing the entire system.

---

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗