VCode home

Memory limits and parking idle tabs

Agents: claude · On: desktop, phone

The v-code.service unit runs inside a cgroup with a hard memory ceiling. Near the ceiling the server refuses to open another tab, and under real pressure it stops idle claude processes so the kernel does not have to.

Why you would use it

Every agent and its children run inside this one unit's cgroup. A test run with 27 workers inside a tab can take the whole desktop down. The cap is what keeps the kill inside VCode.

How to use it

  1. Check what is set: systemctl --user show v-code -p MemoryHigh -p MemoryMax -p MemorySwapMax
  2. Raise it persistently on a machine with room: systemctl --user set-property v-code MemoryHigh=16G MemoryMax=18G
  3. These apply immediately. No restart, and the server re-reads the cgroup per request, so a new cap takes effect on the next tab you open.

Never set MemoryHigh above MemoryMax: the hard cap would fire first.

What you see

The journal logs one line per parked tab: parked <thread-id> after 4 min idle, and parked idle claude process from the runner. The 503 a user meets when the cap is close, and what a parked tab feels like from the phone, are in memory-headroom-and-idle-parking.

Options and settings

Option Default What it changes
MemoryHigh 8G Where cgroup reclaim and throttling begin
MemoryMax 12G The hard ceiling. The OOM kill lands inside this cgroup
MemorySwapMax 2G How much swap the unit may use
OOMPolicy continue An agent child killed by the OOM killer does not take VCode with it

The guard's own thresholds — new-tab headroom, parking headroom, idle time, reaper interval, CPU mark — are constants in lib/memory-guard.js and are listed in memory-headroom-and-idle-parking.

Limits and known gaps