# [BUG] Extreme memory and CPU usage on WSL2 causing system instability
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?
Preflight Checklist
- [x] I have searched existing issues and found related issue #15689
- [x] This is a single bug report
- [x] I am using a recent version of Claude Code
Environment
- Claude Code Version: 2.1.7
- OS: Windows 11 with WSL2 (Ubuntu)
- WSL Version: WSL2
- Hardware:
- CPU: Intel Core i7-13700HX (16 cores, 24 logical processors, 2100 MHz)
- RAM: 32GB (24GB allocated to WSL2)
- GPU: NVIDIA RTX 4070
- Terminal: VS Code Remote - WSL
Description
Claude Code consumes excessive memory and CPU resources on WSL2, eventually causing VS Code to lose connection to WSL. This appears related to #15689 but involves sustained high resource usage beyond just the slash command menu.
Observed Behavior
Memory and CPU usage grow unbounded during normal usage:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2262 furkan 20 0 73.2g 21.1g 28224 R 340.7 89.7 7:36.99 claude
- Virtual memory: 73.2 GB
- Resident memory: 21.1 GB (89.7% of available WSL memory)
- CPU: 340%+ sustained
This eventually causes:
- VS Code shows "Reconnecting to WSL..." modal
- Connection never recovers
- Requires
wsl --shutdownto restore functionality
Steps to Reproduce
- Install Claude Code on WSL2 Ubuntu
- Open a project in VS Code via Remote - WSL
- Start Claude Code and use it normally (not just slash commands)
- Monitor with
top- observe memory climbing over time - Eventually VS Code loses connection to WSL
Expected Behavior
- Memory usage should remain stable during normal operation
- CPU should return to idle when not actively processing
- Should not destabilize the WSL environment
Workarounds Attempted
- Increased WSL memory allocation to 24GB (
.wslconfig) — delays but doesn't prevent the issue - Cleared VS Code server (
rm -rf ~/.vscode-server) — no effect - Verified inotify watches are high (524288) — not the cause
Diagnostic Data
Initial state:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2538 furkan 20 0 73.1g 4.7g 56064 S 29.9 30.7 0:34.16 claude
After ~10 minutes of use:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2262 furkan 20 0 73.2g 21.1g 28224 R 340.7 89.7 7:36.99 claude
Memory grew from 4.7GB to 21.1GB during normal usage session.
Related Issues
- #15689 - Slash command futex spinlock (related but this occurs outside of slash commands too)
- #14991 - High CPU usage when opening menu list with "/"
Additional Context
Running alongside Next.js dev server. The combination of both processes exhausts WSL memory allocation, but Claude Code is the primary consumer and continues growing unbounded.
Impact
Makes Claude Code unusable for extended sessions on WSL2. Users must periodically kill the process or restart WSL to continue working.
What Should Happen?
this happens only lately
Error Messages/Logs
Steps to Reproduce
run latest version on a next js project.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.7 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
13 Comments
Same here
<img width="1888" height="235" alt="Image" src="https://github.com/user-attachments/assets/f19c9ae8-f0b1-402b-8d9e-6c01c8681355" />
same here, even I do nothing just keep the claude code open
WSL2 on Intel, 32 GB total RAM, Claude CLI 2.1.68
claudefor 1~2 rounds, the WSL hangs, I have to runwsl --shutdownand restart WSL.claudefor 10+ rounds,%MEMgrows to 90%+, the WSL hangs but soon recovers, I found claudeKilledby OS.claudefor 30+ rounds,%MEMis 50%~60%, the WSL doesn't hang any more, however after I'm back from a sleep, theclaudeprocess wasKilledby OS, not sure when. UPDATE: claude saysHigh memory usage (19.8GB)andKilled.I'm surprised it goes up to 40+GB, a
/compactdoesn't help. As requested by claude, I've run/heapdump, the result are as follows:3c2ba436-f939-4b5d-aef7-54be951b2eea-diagnostics.zip
Environment:
.wslconfigmemory limit)Observations:
claudealready at 74.8GB VIRT / 761MB RSS / 62% CPU/heapdump)Additional note: The low WSL memory default (50% of host RAM on systems with ≤16GB) makes this issue especially severe for users who haven't tuned
.wslconfig. Even users with 16GB physical RAM only get ~8GB in WSL by default, which theclaudeprocess can exhaust in minutes.Follow-up — possible AMD correlation:
Looking at the reports so far, both AMD users seem to hit the memory blow-up faster/harder:
| User | CPU | WSL RAM | Outcome |
|------|-----|---------|---------|
| @timorieber | AMD | 10GB | OOM-killed in a short, fresh session (9.6GB RSS) |
| me (Josep) | AMD Ryzen 5 7520U | 7.4GB | 74.8GB VIRT within ~3 min of fresh session |
| @evisong | Intel | 8-24GB | Survives longer (10-30+ rounds before OOM) |
| OP @furkanakkurt1335 | Intel i7-13700HX | 24GB | Grows over ~10 min from 4.7GB to 21.1GB |
AMD users appear to reach critical memory levels significantly faster than Intel users with comparable setups. Could be coincidence with small sample size, but worth investigating whether there's a platform-specific code path (e.g. V8/Node memory allocation behavior differing on AMD).
Another data point — regression accelerating over versions:
From my experience (AMD Ryzen 5 7520U, WSL2, 7.4GB RAM): last week the memory issue was present but manageable — sessions could run for a reasonable time. This week (v2.1.72) it's hitting critical levels within minutes of a fresh session. The problem seems to be getting worse with each release, not just present.
The original reporter also noted: "this happens only lately" and marked it as a regression. Combined with the version progression visible in comments (2.1.58 → 2.1.68 → 2.1.72), the leak appears to be worsening across updates.
Analysis: Memory growth is proportional to cumulative usage, not just session time
Adding some data from investigating locally. The theory: this isn't just a within-session leak — it's cumulative across sessions. The more you've used Claude Code historically, the worse each new session behaves.
Evidence:
~/.claude/directory is 1.1GB total:projects/— 893MB (session JSONL files + tool-results from past sessions)debug/— 117MBtelemetry/— 40MBfile-history/— 28MBThis data accumulates with each session and is never pruned. If Claude Code loads/indexes this on startup or during operation, it explains the baseline memory being higher for heavy users.
~/.claude/. Yesterday's session added more data → today's session starts with a bigger footprint and grows faster./compactdoesn't help (@evisong confirmed): This makes sense —/compacttrims conversation context, but the accumulated project data, tool-results, debug logs, and telemetry remain fully loaded/referenced.The pattern:
Suggested investigation for the team:
Environment: Claude Code 2.1.72, WSL2, AMD Ryzen 5 7520U, 7.4GB WSL RAM, Node v20.19.5
Update: Since Claude Code v2.1.74 it's running ok, I no longer have this problem. Thanks a lot to the team.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
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.