Why AI Coding Tools Eat Your RAM (And How to Fix It)
Source: Dev.to
The Problem
If you use Claude, Code, Codex, or similar AI coding assistants, you’ve probably noticed your machine getting slower over time—RAM usage creeping up, fans spinning, and eventually needing a force‑restart. Most people blame the AI tool, but the real culprit is usually orphaned child processes.
Every time you start a Claude/Code session it spawns child processes. When the session ends—especially after a crash or a force‑quit—these children don’t always exit. They become orphans, still running and still consuming RAM.
How Bad Is It?
I discovered this the hard way on a MacBook Pro with 32 GB of RAM that ground to a halt:
- Load average: 2.30 (normal is ~0.4–0.8)
- RAM consumed by idle processes: ~22 GB
Why This Happens
The root cause is simple: process‑lifecycle management is hard. When a Claude/Code session exits normally it tries to clean up, but each session leaves a few survivors. After a week of heavy use you can have dozens of zombie processes lingering.
The Fix: zclean
I built zclean, a small CLI that automatically finds and cleans up these orphaned processes.
Installation
npx thestackai zclean initThis command sets up two layers of protection.
Safety Model
The most important design decision is: if the parent process is alive, don’t touch it. zclean only kills processes that are:
- Your intentional
vite devserver in a terminal tab → Untouched - Your
node api.jsin tmux → Untouched - Only true zombies from dead AI sessions → Killed
See It In Action
zcleanFound 8 zombie processes
PID 26413 node 367 MB orphan 18h (was claude mcp server)
Total: 8 zombies, 20 GB reclaimablezclean yesCleaned 8 zombie processes
Reclaimed 20 GBCheck for Zombies
You can manually inspect the Task Manager for inactive node processes that are zombies, or simply run:
npx thestackai zcleanLinks
- GitHub:
- NPM:
Contributions are welcome.