Freeing 400 MB idle processes without breaking anything: ship the cleanup in dry-run first
Description and use
Reaping idle Relaymote CLI processes frees ~400 MB per session by invoking the app’s teardown path, with a 24‑hour dry‑run to audit decisions.
Problem
Open sessions in Relaymote keep ~400 MB CLI processes alive even when idle, wasting memory.
Outcome
After implementing the reaper, idle sessions older than three hours are terminated safely, reducing memory usage by ~400 MB per session without disrupting active work.
Workflow
- Identify idle sessions by checking running state, pending user input, CLI idleness, idle duration, unread activity, and protected goals.
- Collect reasons for sparing a session; if any reason exists, skip termination.
- If no reasons, invoke the app’s teardown routine to clean up the session.
- Log each decision with a "WOULD‑REAP" entry during dry‑run, then switch to live mode after 24 hours.
- Cap releases to a maximum of six sessions per tick and measure memory before acting.
- Maintain a dry‑run period to audit decisions before enabling live cleanup.
- Ensure permanent exclusions (e.g., Remote Control sessions) are not configurable.
Evidence
Relaymote (MIT, Node.js) is a phone remote for Claude Desktop's Code‑tab sessions. People who use it tend to keep a lot of sessions open, and every open session keeps a CLI process alive, with its tool servers, at roughly 400 MB each, whether anyone is talking to it or not.
The app already has a teardown routine it uses itself when a query ends. Calling that instead leaves the session exactly as a freshly launched app would: the record and transcript intact, no process.
Why three hours? Because after an hour the session's prompt cache has expired anyway, so the next message pays the cold-start cost whether the process was kept or not.
- Record date: 2026-10-27T07:11:57.444Z