claude-code - 💡(How to fix) Fix [BUG] claude process leaks to 74 GB virtual memory, causing full system OOM freeze [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#56335Fetched 2026-05-06 06:30:53
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
labeled ×5commented ×2subscribed ×1

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

Workaround applied

Code Example

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,2053,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
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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:

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,2053,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

```shell

Steps to Reproduce

. Install Claude Code 2.1.128 on Ubuntu 24.04 (32 GB RAM, 2 GB swap). 2. Install and enable the Codex companion plugin (codex-openai-codex). 3. Configure MCP servers: contextpool (cxp 0.1.18, stdio) and jina-ai (HTTP).
4. Use Claude Code normally across multiple sessions over several hours. 5. Observe ~/.claude/session-env/ accumulating thousands of directories
(3,279 in a single day), each containing a Codex sessionstart hook script.
6. Monitor claude process virtual memory — it grows unbounded over time.
7. 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

extent analysis

TL;DR

The likely fix involves addressing the Codex companion plugin's session loop issue, which is causing the claude binary to grow in memory unbounded.

Guidance

  • Investigate the Codex companion plugin's sessionstart hook to determine why it is firing in a loop, rather than once per session.
  • Consider implementing a mechanism to limit the number of sessions created by the plugin or to properly clean up session directories after use.
  • Monitor the claude process's memory usage and the accumulation of session directories in ~/.claude/session-env/ to verify the effectiveness of any fixes.
  • Review the plugin's configuration and the MCP server setup to ensure they are not contributing to the issue.

Example

No code example is provided as the issue is related to a specific plugin and its interaction with the claude binary, and the exact implementation details are not specified.

Notes

The exact trigger for the session loop is unknown, and the issue may be related to the specific configuration and usage of the Codex companion plugin. Further investigation is needed to determine the root cause and develop a comprehensive fix.

Recommendation

Apply a workaround, such as regularly cleaning up the session-env directory or implementing a custom solution to limit the number of sessions created by the plugin, until a permanent fix is available. This is because the issue is causing significant system instability and the exact cause is still unknown.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] claude process leaks to 74 GB virtual memory, causing full system OOM freeze [2 comments, 2 participants]