Claude Code Slow, Hanging, or Eating Memory? Start With the Silent Failures
High CPU, frozen commands and missing search results usually trace to a handful of specific causes — a thrashing auto-compact loop, a bundled ripgrep that won't run, or WSL quietly returning fewer matches while claude doctor reports everything as OK.
If Claude Code is slow, hanging, or eating memory, the useful first move is /doctor — it checks your installation, settings, extensions and context usage, and proposes fixes it can apply after you confirm. If it won't start at all, run claude doctor from your shell instead.
But the causes worth knowing are the ones that produce no error at all. Slowness that announces itself is easy; what costs you a day is the failure that reports everything as fine.
The silent one: search quietly returns fewer results on WSL
This is the failure I'd check first if you're on Windows, because nothing tells you it's happening.
Working across file systems on WSL carries a disk read performance penalty, and the practical effect is that searches return fewer matches than they should. Search still works. It just misses things.
And the part that makes it genuinely nasty:
claude doctorshows Search as OK in this case.
So you get a green check, an agent that seems to not understand your codebase, and no error anywhere. Three fixes, in order of effectiveness:
- Move the project onto the Linux filesystem —
/home/rather than/mnt/c/. This removes the penalty rather than working around it. - Run natively on Windows instead of through WSL, for better filesystem performance.
- Narrow your searches — "Search for JWT validation logic in the auth-service package" instead of a repo-wide sweep.
The other silent one: bundled ripgrep won't run
If the Search tool, @file mentions, custom agents or custom skills aren't finding files, the bundled ripgrep binary may not run on your system at all.
Install your platform's package:
# macOS
brew install ripgrep
# Ubuntu/Debian
sudo apt install ripgrep
# Windows
winget install BurntSushi.ripgrep.MSVCThen point the CLI at it, either in your shell environment or the env block of settings.json:
{
"env": {
"USE_BUILTIN_RIPGREP": "0"
}
}Verify it actually took effect rather than assuming: run claude doctor and check that the Search line shows the path to your system ripgrep instead of OK (bundled).
Autocompact is thrashing — what it actually means
If you hit this:
Autocompact is thrashing: the context refilled to the limit...it does not mean compaction failed. Compaction succeeded — and then a file or tool output immediately refilled the context window, several times in a row. It stops retrying deliberately, to avoid burning API calls on a loop that isn't making progress.
That tells you the real problem: something in your workflow is dumping an enormous payload into context. Recovery, in order:
- Ask Claude to read the oversized file in chunks — a line range or a single function, not the whole file.
- Run
/compactwith a focus that drops the offending output:/compact keep only the plan and the diff. - Move the large-file work to a subagent so it runs in its own context window and only a summary comes back.
/clearif the earlier conversation no longer matters.
A related gotcha: /compact can return Not enough messages to compact. even when your context is full — that happens when a single large paste filled it, so there aren't enough turns to summarize.
High CPU or memory
Work through these before reaching for diagnostics:
/compactregularly to keep context size down.- Restart between major tasks. Long-lived sessions accumulate.
- Add large build directories to
.gitignore. - Restart with
claude --safe-mode. This is the one people skip, and it's the highest-signal step: it disables every customization for the session. If usage drops, a plugin, MCP server or hook is your culprit, and you can bisect from a clean configuration.
If memory stays high after all that, /heapdump writes a heap snapshot and a diagnostics file to your Desktop, and prints a summary showing resident set size, JS heap, array buffers and unaccounted native memory, plus leak indicators like a high growth rate or an unusual number of open handles. The command doesn't appear in the command menu — type it in full.
⚠️ Do not attach the .heapsnapshot to a public issue. It contains every string in the process, which means your full conversation and your credentials. If you're reporting a bug, attach only the -diagnostics.json, which carries the statistics and no conversation content.
The summary also tells you whether memory is in the JS heap — which the snapshot captures, and which you can inspect in Chrome DevTools under Memory → Load, sorted by retained size — or in native memory, which it doesn't capture at all.
Hangs, and the fear of losing your session
If the CLI stops responding: press Ctrl+C to cancel the current operation. If it stays unresponsive, close the terminal.
Restarting doesn't lose your conversation. Run claude --resume in the same directory and pick the session back up. People tolerate a frozen terminal for far too long because they assume otherwise.
Two display problems that look like bugs
Slow rendering is one thing; garbled or corrupted text in the VS Code, Cursor or Devin Desktop integrated terminal is another — characters rendering as boxes, smears or wrong glyphs — is almost always the terminal's GPU renderer. Run /terminal-setup to switch terminal.integrated.gpuAcceleration to "off", then reload the window.
A truncated table isn't data loss. A Markdown table over 200 rows renders the first 200 followed by … N more rows not shown. Only the display is capped — the full table is still in the conversation, and /copy copies every row. For anything genuinely large, ask Claude to write it to a file instead.
When it's cost, not performance
Being slow and being expensive get conflated, and they have different fixes. If the symptom is your plan limit disappearing rather than the CLI feeling sluggish, the causes are different — long context re-sent on every turn, prompt cache expiry, idle sessions still spending. I covered those separately in why Claude Code burns tokens while you're not even using it.
And if the symptom is specifically that tools aren't available rather than slow, that's usually configuration rather than performance — see MCP server not showing up in Claude Code.
Key takeaways
- On WSL, search silently returns fewer matches when working across filesystems — and claude doctor still reports Search as OK. Move the project to /home/ rather than /mnt/c/.
- If files aren't being found at all, the bundled ripgrep may not run. Install your own and set USE_BUILTIN_RIPGREP=0, then confirm the path in claude doctor.
- 'Autocompact is thrashing' means compaction worked and something immediately refilled the context. Fix the payload, don't retry the compaction.
- claude --safe-mode disables every customization for one session — the fastest way to prove whether a plugin, MCP server or hook is responsible.
- Restarting never loses your conversation. Ctrl+C, then claude --resume in the same directory.
Frequently asked questions
Why does Claude Code say autocompact is thrashing?
Automatic compaction succeeded, but a file or tool output immediately refilled the context window several times in a row. Claude Code stops retrying rather than burning API calls on a loop that is not making progress. Recover by reading the oversized file in chunks, running /compact with a focus that drops the large output, moving that work to a subagent, or clearing if the earlier conversation no longer matters.
Why is Claude Code not finding files that definitely exist?
The bundled ripgrep binary may not run on your system. Install your platform's ripgrep package and set USE_BUILTIN_RIPGREP to 0, then confirm with claude doctor that the Search line shows your system ripgrep path instead of OK (bundled). On WSL there is a second cause: searching across the Windows filesystem returns fewer matches than expected, and claude doctor still reports Search as OK.
Will restarting Claude Code lose my conversation?
No. If a command hangs, press Ctrl+C first; if it stays unresponsive, close the terminal. Run claude --resume in the same directory afterwards to pick the session back up.
How do I tell whether a plugin or MCP server is causing high resource usage?
Restart with claude --safe-mode, which disables every customization for that session. If usage drops, one of your plugins, MCP servers or hooks is responsible, and you can bisect from there against a clean configuration.
The pattern across all of these: the loud problems are the easy ones. A hang tells you it's hung. What costs you a day is search quietly returning half the matches while every diagnostic reports OK — so when the agent seems to have stopped understanding your codebase, check the silent failures before you rewrite your CLAUDE.md.
I run Claude Code on Windows daily, which is where most of these bite hardest; ContextZero came out of the adjacent problem of controlling what these tools know about a project in the first place.
References
- Troubleshooting — Claude Code docscode.claude.com · accessed 2026-08-16
- Manage costs effectively — Claude Code docscode.claude.com · accessed 2026-08-16
- Working across file systems — WSL documentationlearn.microsoft.com · accessed 2026-08-16
Last reviewed August 16, 2026
Tahir Nazir
Senior AI Engineer & Full-Stack Lead
5+ years shipping AI-powered products — RAG pipelines, agentic workflows, and MCP tooling. Top Rated on Upwork with a 100% job success score.
More about Tahir →Keep reading
New posts land here first. Follow along by RSS, or get in touch if you are building something similar.
Related articles
Why Claude Code Burns Tokens While You're Not Even Using It
Your usage climbs during a long session even when you barely type. The reasons are specific and mostly invisible: every request carries the whole conversation, your prompt cache quietly expires, and scheduled tasks, cross-session messages and idle teammates each resend your full context.TroubleshootingAI Engineering10 min readMCP Server Not Showing Up in Claude Code? Read the Status First
Your MCP server is configured but Claude can't see it. `claude mcp list` tells you which of five different problems you actually have — pending approval, a failed spawn, a Windows .cmd shim, zero advertised tools, or a server that was never in the list to begin with.TroubleshootingAI Engineering11 min readClaude Code vs Cursor: How Each One Decides What Your Agent Knows
Both tools read project instructions from disk, but they disagree on file names, load order, and scoping. Here is the concrete difference — and how to keep one repo working well in both.ComparisonAI Engineering8 min read