[BUG] claude process leaks to 74 GB virtual memory, causing full system OOM freeze
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?
Version: 2.1.128
OS: Ubuntu 24.04, kernel 6.8.0-111-generic
RAM: 32 GB | Swap: 2 GB (swapfile)
## Description
The claude binary repeatedly grew to ~74 GB of virtual memory during normal use, eventually exhausting all RAM and swap. The system became completely unresponsive (no TTY switching)
Mai 05 16:54:02 kernel: Out of memory: Killed process 7595 (claude)
total-vm:74471564kB, anon-rss:163596kB
At time of kill:
- Free swap: 116 KB of 2 GB total
- Free RAM pages: ~197 MB
## Likely contributing factor: Codex plugin session loop
~/.claude/session-env/ contained 6,205 session directories, with 3,279
created on the day of the freeze — roughly one every 26 seconds. Each
directory is created by the Codex companion plugin's startup hook:
```sh
export CODEX_COMPANION_SESSION_ID='<uuid>'
export CLAUDE_PLUGIN_DATA='/home/laroy/.claude/plugins/data/codex-openai-codex'
This abnormal session-creation rate (codex-openai-codex plugin firing a
sessionstart hook in a loop) is likely feeding the memory growth in the
main claude process.
Active MCP servers at time of freeze
- contextpool (cxp 0.1.18, stdio) — 4.4 MB RSS, not the cause
- jina-ai (HTTP)
- Codex companion plugin
Impact
Complete system freeze, no interactive recovery possible. Required hard reboot.
Occurred multiple times in one day.
Workaround applied
- Installed earlyoom
- Cleaned up session-env directory (6,205 → 3,279 entries)
What Should Happen?
The claude process should maintain a stable memory footprint during normal use
and release memory after operations complete. It should not grow unbounded
regardless of session length or number of MCP/plugin calls. The Codex companion
plugin's sessionstart hook should fire once per session, not repeatedly in a loop.
Error Messages/Logs
Steps to Reproduce
. Install Claude Code 2.1.128 on Ubuntu 24.04 (32 GB RAM, 2 GB swap).
- Install and enable the Codex companion plugin (codex-openai-codex).
- Configure MCP servers: contextpool (cxp 0.1.18, stdio) and jina-ai (HTTP).
- Use Claude Code normally across multiple sessions over several hours.
- Observe ~/.claude/session-env/ accumulating thousands of directories
(3,279 in a single day), each containing a Codex sessionstart hook script.
- Monitor claude process virtual memory — it grows unbounded over time.
- System eventually exhausts RAM and swap; OOM killer fires and the system
freezes completely.
Note: Exact trigger for the session loop is unknown. The sessionstart hook
fires far more frequently than actual user-initiated sessions, suggesting the
Codex plugin is re-triggering it internally.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.128
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗