claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Memory leak - Claude Code 2.1.2 grows to 6-7GB RAM in short conversations

Open imurodl opened this issue 10 months ago • 2 comments

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?

Environment

  • Claude Code version: 2.1.2
  • OS: Arch Linux (kernel 6.18.3)
  • RAM: 8GB
  • Node.js: (run node --version to get this)

Description

Claude Code consumes 6-7GB RAM within minutes of normal conversation, leading to OOM kills. This did not happen in previous versions.

Observed behavior

  • Memory grows continuously during conversation
  • Reaches 6-7GB within 2-3 minutes
  • Gets killed by OOM killer
  • --max-old-space-size=2048 does not help (process still grows to 4-5GB, suggesting native memory leak)

What Should Happen?

Memory should stay under 2-3GB for normal conversations.

Error Messages/Logs

OOM killer output:
  oom-kill: task=claude, pid=2552, total-vm:74858512kB, anon-rss:6702608kB

Steps to Reproduce

Steps to reproduce

  1. Start Claude Code normally: claude
  2. Have a short conversation (5-10 messages)
  3. Monitor memory: watch -n 1 'ps aux --sort=-%mem | head -3'
  4. Observe RSS growing from ~1GB to 6-7GB rapidly

Workaround

Using systemd-run --user --scope -p MemoryMax=3G claude to hard-cap memory, but this causes frequent kills.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.2 (Claude Code)

Platform

Anthropic API

Operating System

Arch Linux

Terminal/Shell

Ghostty

imurodl avatar Jan 11 '26 12:01 imurodl

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/16325
  2. https://github.com/anthropics/claude-code/issues/12987
  3. https://github.com/anthropics/claude-code/issues/11315

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Jan 11 '26 12:01 github-actions[bot]

i rolled back to 2.1.1 version and i cleared the cashe and history.json, now it is working appropriate

imurodl avatar Jan 11 '26 13:01 imurodl

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Feb 11 '26 10:02 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Mar 02 '26 14:03 github-actions[bot]