CLI process memory accumulates across context resets, not freed until exit

Resolved 💬 3 comments Opened Jan 28, 2026 by ldraney Closed Feb 1, 2026

Description

Claude CLI processes accumulate memory over time that is not freed when using /clear or /compact. On memory-constrained machines (e.g., 8 GB MacBook Air), this leads to heavy swap usage and system slowdowns.

Observed behavior

  • Long-running Claude CLI sessions grow to hundreds of MB even with regular context resets
  • /clear and /compact reset the API conversation but don't release process memory
  • Only way to reclaim memory is to fully /exit and restart

Evidence from my system

PID    %MEM   RSS (MB)  
78970  11.4%  953 MB    <- single claude process
55695   4.2%  348 MB
98874   2.7%  225 MB
38583   2.5%  208 MB

Total: ~2 GB across 10 CLI sessions, despite regular context resets.

System had 5.7 GB swap used with only 160 MB free RAM.

Expected behavior

When user runs /clear, internal buffers/history should be freed, not just the API context.

Possible solutions

  1. Free internal scrollback/history buffers on /clear
  2. Add a /gc or /free-memory command to explicitly release memory
  3. Warn users when CLI memory exceeds a threshold (e.g., 500 MB)
  4. Document that long-running sessions accumulate memory and should be restarted periodically

Environment

  • macOS (Darwin 25.2.0)
  • MacBook Air, 8 GB RAM
  • Claude Code (latest)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗