# [BUG] Extreme memory and CPU usage on WSL2 causing system instability

Status Closed — not planned
Reported on v2.1.7
Maintainer reply None cached
Activity 13 comments · opened Jan 14, 2026 · closed Apr 15, 2026

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:

  1. VS Code shows "Reconnecting to WSL..." modal
  2. Connection never recovers
  3. Requires wsl --shutdown to restore functionality

Steps to Reproduce

  1. Install Claude Code on WSL2 Ubuntu
  2. Open a project in VS Code via Remote - WSL
  3. Start Claude Code and use it normally (not just slash commands)
  4. Monitor with top - observe memory climbing over time
  5. 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_

View original on GitHub ↗

13 Comments

Sybio · 6 months ago

Same here

timorieber · 6 months ago
  • Claude CLI 2.1.58 ~9.6 GB RSS in a short, fresh session
  • WSL2 on AMD, 16 GB total RAM, memory=10GB, swap=4GB
  • Kernel OOM-killed the process after exhausting all swap
NathanSmeltzer · 6 months ago

<img width="1888" height="235" alt="Image" src="https://github.com/user-attachments/assets/f19c9ae8-f0b1-402b-8d9e-6c01c8681355" />

suguanYang · 5 months ago

same here, even I do nothing just keep the claude code open

evisong · 5 months ago

WSL2 on Intel, 32 GB total RAM, Claude CLI 2.1.68

  • 1st try: WSL configured memory=8GB, swap=8GB, after using claude for 1~2 rounds, the WSL hangs, I have to run wsl --shutdown and restart WSL.
  • 2nd try: WSL configured memory=16GB, swap=8GB, claude for 10+ rounds, %MEM grows to 90%+, the WSL hangs but soon recovers, I found claude Killed by OS.
  • 3rd try: WSL configured memory=24GB, swap=8GB, claude for 30+ rounds, %MEM is 50%~60%, the WSL doesn't hang any more, however after I'm back from a sleep, the claude process was Killed by OS, not sure when. UPDATE: claude says High memory usage (19.8GB) and Killed.
evisong · 5 months ago
WSL2 on Intel, 32 GB total RAM, Claude CLI 2.1.68 * 3rd try: WSL configured memory=24GB, swap=8GB, claude for 30+ rounds, %MEM is 50%~60%, the WSL doesn't hang any more, however after I'm back from a sleep, the claude process was Killed by OS, not sure when. UPDATE: claude says High memory usage (19.8GB) and Killed.

I'm surprised it goes up to 40+GB, a /compact doesn't help. As requested by claude, I've run /heapdump, the result are as follows:
3c2ba436-f939-4b5d-aef7-54be951b2eea-diagnostics.zip

josepportell · 5 months ago

Environment:

  • Claude Code: 2.1.72, Claude Opus 4.6
  • OS: WSL2 Ubuntu on Windows (kernel 6.6.87.2)
  • CPU: AMD Ryzen 5 7520U
  • RAM: 7.4GB total WSL allocation (no custom .wslconfig memory limit)
  • Node: v20.19.5
  • Terminal: VS Code Remote - WSL

Observations:

  • Fresh session (~3 min in): claude already at 74.8GB VIRT / 761MB RSS / 62% CPU
  • Several MCP servers running (Playwright, Firecrawl, Sequential Thinking) adding ~400MB combined
  • VS Code file watcher consuming 519MB at 88% CPU, competing for the same limited RAM
  • Two heap snapshots generated: 32MB and 44MB (/heapdump)
  • With only 7.4GB WSL RAM, OOM kills happen quickly — makes Claude Code unusable for extended sessions

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 the claude process can exhaust in minutes.

josepportell · 5 months ago

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).

josepportell · 5 months ago

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.

josepportell · 5 months ago

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:

  1. Local storage accumulation: My ~/.claude/ directory is 1.1GB total:
  • projects/ — 893MB (session JSONL files + tool-results from past sessions)
  • debug/ — 117MB
  • telemetry/ — 40MB
  • file-history/ — 28MB

This 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.

  1. "Idle" growth explained: @suguanYang reports memory growing even idle. This is consistent: the process isn't truly idle — it has MCP servers, file watchers, and background indexing operating on an ever-larger data set. More historical data → more work even when "idle."
  1. "Faster today than yesterday": From my experience — memory grows faster in new sessions compared to earlier in the week. Same hardware, same WSL config. The only variable that changed is the accumulated state in ~/.claude/. Yesterday's session added more data → today's session starts with a bigger footprint and grows faster.
  1. /compact doesn't help (@evisong confirmed): This makes sense — /compact trims conversation context, but the accumulated project data, tool-results, debug logs, and telemetry remain fully loaded/referenced.

The pattern:

  • Fresh install → manageable memory, slow growth
  • After days/weeks of heavy use → 1GB+ of accumulated local data → higher baseline RSS, faster growth, quicker OOM on WSL
  • WSL's memory ceiling (often just 50% of host RAM by default) makes this fatal much sooner than on native Linux/Mac

Suggested investigation for the team:

  • Are past session JSONL files and tool-results loaded into memory on startup or during session resume?
  • Is there an unbounded cache/map that indexes historical sessions?
  • The heapdump from @evisong should show which objects are retaining the most memory

Environment: Claude Code 2.1.72, WSL2, AMD Ryzen 5 7520U, 7.4GB WSL RAM, Node v20.19.5

josepportell · 5 months ago

Update: Since Claude Code v2.1.74 it's running ok, I no longer have this problem. Thanks a lot to the team.

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 4 months ago

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.