Answer: Use `/compact` regularly to reduce context size, close and restart Claude Code between major tasks, add large build directories to `.gitignore`, and restart with `claude --safe-mode` to check whether a plugin, MCP server, or hook is the source. If a session's heap memory passes 2.5GB, restart Claude Code and run `claude --continue` to resume in a fresh process. Status: Confirmed Entry: tool/claude-code/troubleshooting/fix-high-cpu-memory-usage Revision: 2 Digest: sha256:42ecd9a5493e2be0 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:06:02Z Last changed: 2026-11-19T12:21:08Z (diagnostics file name: — → -diagnostics.json) Last verified: 2026-11-20T12:26:04Z Next check: 2026-11-21T12:26:04Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Unit | Source | As of heap memory warning threshold | 2.5GB | GB | [1] | 2026-11-20 resume command | claude --continue | | [1] | 2026-11-20 safe mode command | claude --safe-mode | | [1] | 2026-11-20 compact command | /compact | | [1] | 2026-11-20 heapdump command | /heapdump | | [1] | 2026-11-20 diagnostics file name | -diagnostics.json | | [1] | 2026-11-20 Sources: [1] Anthropic. "Troubleshooting". https://code.claude.com/docs/en/troubleshooting.md Role: primary. Accessed: 2026-11-20T12:26:04Z Quote: "If a session's heap memory passes 2.5GB, a critical memory usage warning appears." (Supports: heap memory warning threshold) Quote: "restart Claude Code and run [`claude --continue`]" (Supports: resume command) Quote: "Restart with [`claude --safe-mode`]" (Supports: safe mode command) Quote: "Use `/compact` regularly to reduce context size." (Supports: compact command) Quote: "run `/heapdump` to write two files to `~/Desktop`" (Supports: heapdump command) Quote: "a memory breakdown named `-diagnostics.json`" (Supports: diagnostics file name) Published: 2026-11-20T03:38:58Z Snapshot SHA-256: 2d4ff8345bc6e72a09bccde71014dafbc5be06feeee31d54dfced5f9d477eecc (captured 2026-11-18T12:20:55Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-18T12:20:55Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:26:04Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:26:04Z Last attempt: 2026-11-20T12:26:04Z Notes and limitations: Extracted automatically from a single official source (section "High CPU or memory usage"). Related: https://latestn.com/tool/claude-code/troubleshooting/fix-invalid-api-key How do I fix the Claude Code "Invalid API key" error? https://latestn.com/tool/claude-code/troubleshooting/fix-marketplace-not-found How do I fix the "Marketplace not found" error when adding a marketplace in Claude Code? https://latestn.com/tool/claude-code/troubleshooting/fix-plugin-installed-not-working How do I fix a Claude Code plugin that is installed but not working or not showing up? https://latestn.com/tool/claude-code/troubleshooting/fix-command-not-found How do I fix 'command not found: claude' after installing Claude Code? https://latestn.com/tool/claude-code/troubleshooting/fix-commands-path-not-found How do I fix the "commands path not found" error when building a Claude Code plugin? https://latestn.com/tool/claude-code/troubleshooting/fix-garbled-text-integrated-terminal How do I fix garbled or corrupted text in an editor's integrated terminal when using Claude Code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-19T12:21:08Z | changed | diagnostics file name: — → -diagnostics.json | [1] 2026-11-19T12:21:08Z | changed | safe mode command: — → claude --safe-mode | [1] 2026-11-19T12:21:08Z | changed | resume command: — → claude --continue | [1] 2026-11-19T12:21:08Z | changed | diagnostics file: -diagnostics.json → — | [1] 2026-11-19T12:21:08Z | changed | continue command: claude --continue → — | [1] 2026-11-19T12:21:08Z | changed | safe mode flag: claude --safe-mode → — | [1] 2026-11-13T03:06:02Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage POST: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I fix high CPU or memory usage in Claude Code? Revision 2, last verified 2026-11-20T12:26:04Z. https://latestn.com/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage (accessed 2026-11-21T09:54:43Z). @misc{LatestN_tool_claude_code_troubleshooting_fix_high_cpu_memory_usage_r2, title = {How do I fix high CPU or memory usage in Claude Code?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage}}, note = {Revision 2; digest sha256:42ecd9a5493e2be0; last verified 2026-11-20T12:26:04Z; accessed 2026-11-21T09:54:43Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/troubleshooting/fix-high-cpu-memory-usage