15 Claude Code sessions were sitting on 11 GB of RAM. I built a mod to see which one
Описание и применение
Мод claude-load позволяет точно определить, какие сессии Claude Code потребляют память и CPU, и безопасно завершать их, снижая потребление памяти с 11 ГБ до управляемого уровня.
Задача
Multiple Claude Code sessions consume excessive RAM and CPU, making it hard to identify which session is responsible for high resource usage.
Результат
The claude-load mod enables precise identification and safe termination of high‑resource Claude Code sessions and orphan processes, reducing memory usage from 11 GB to manageable levels while keeping overall CPU overhead below 1 %.
Рабочий процесс
- 1. Read session registry files in ~/.claude/sessions/*.json to map PIDs to session IDs and names.
- 2. Build a process tree by walking PPID chains, caching results for efficiency.
- 3. Identify orphan trees whose root’s parent is dead or reparented to init/systemd/launchd.
- 4. Filter orphans to include only dev tools with >0.3% CPU or >150 MB memory, excluding shells and the sampler itself.
- 5. For each orphan, resolve its working directory via /proc/
<pid>/cwd (Linux), lsof (macOS), or NtQueryInformationProcess (Windows). - 6. Display sessions and orphans in a UI pane with CPU, memory, and graph data.
- 7. Provide an “end” button that takes a fresh snapshot, checks PID freshness and name, and then terminates the process tree safely.
- 8. Run a single sampler process per machine that writes a snapshot to ~/.claude/state/load/snapshot.json; other sessions read this file every five seconds.
- 9. On Windows, the sampler uses Get-Process for cheap polling and CIM queries only when new PIDs appear.
- 10. On macOS/Linux, a session holds a lease file and performs sampling itself, ensuring only one active sampler.
- 11. The mod enforces strict validation to prevent accidental termination of unrelated processes.
Доказательства
I opened Task Manager and saw what everyone who works like this has probably seen: a wall of identical node and claude processes.
The very first run showed 15 live sessions holding 10.8 GB together.
The sampler takes the list of all processes with their parents and climbs the PPID chain from each one until it hits a session's PID.
On Windows the sampler is a hidden PowerShell process that the mod starts when it sees the snapshot is stale.
- Дата записи: 2026-10-23T22:11:25.654Z