Why 24/7 AI Browser Agents Leak Memory: Headless Chromium Zombie PIDs, 64 MB /dev/shm Crashes & Hard cgroup Caps
Three Linux container defaults quietly break 24/7 AI browser agents like OpenClaw: Docker caps `/dev/shm` at a tiny **64 MB** (crashing Chromium tabs randomly), omitting `init: true` leaves dead Chromium child renderers as zombie processes forever, and uncapped Node/browser pools consume 100% of host RAM. Add `init: true`, `shm_size: "1gb"`, `mem_limit: 3g`, and a 2 GB host swapfile (`vm.swappiness=10`) to keep OpenClaw rock-solid for weeks.
1. The 64 MB /dev/shm Crash Nobody Connects to Docker
If your headless browser agent runs fine on your MacBook and then crashes unpredictably on a Linux VPS with `Target closed` or `RESULT_CODE_KILLED_BAD_MESSAGE`, you probably did NOT run out of VPS RAM. By default, Docker mounts `/dev/shm` (POSIX shared memory used heavily by Chromium’s compositor and raster tiles) at **64 MB**—even on a 32 GB server.
The moment an AI agent opens two modern React/SPA tabs or captures a full-page screenshot, Chromium exhausts 64 MB of `/dev/shm` and the renderer process dies violently. Setting `shm_size: "1gb"` in `docker-compose.yml` eliminates this entire class of phantom crashes.
2. Hardened OpenClaw / Browser-Agent Compose Block
Combine `init: true`, `shm_size: "1gb"`, explicit `pids_limit: 256`, and `NODE_OPTIONS=--max-old-space-size=2048` so a runaway scrape page can never take down your entire VPS:
openclaw:
image: ghcr.io/openclaw/openclaw:latest
restart: unless-stopped
init: true # Reaps zombie Chromium child processes automatically
shm_size: "1gb" # Fixes Docker's 64 MB /dev/shm tab crashes
mem_limit: 3g
pids_limit: 256
environment:
- NODE_OPTIONS=--max-old-space-size=2048
- TZ=UTC