{"slug": "my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it", "title": "My memory guard watched one process grow to 268 GB and did nothing, because it trusted the agent", "summary": "A developer's macOS memory guard failed to stop a runaway node helper process under a live Claude Code session that grew from about 10 GB to 268 GB of memory footprint, pushing swap to 76 GB before the system ran out of application memory. The guard's rule exempted any process belonging to a live agent session, so the helper inherited the agent's immunity; the developer fixed it by adding a ceiling that terminates any process holding at least half of RAM (minimum 16 GB) under critical memory pressure, sending SIGTERM then SIGKILL after 3 seconds, while still sparing system processes, VMs, local model runners and databases. The updated guard, incident fixture and tests are open source in the mac-yolo-safeguards repo.", "body_md": "Yesterday at 2:37 PM, macOS showed \"Your system has run out of application memory\" on my Mac. I run Claude Code all day, and I also run a guard that watches for runaway processes. The guard checked every minute during the whole incident. It stopped nine small leftover processes. It never touched the one that caused the problem.\n\nBetween 2:25 and 2:36 PM, a single node helper running under Claude grew from about 10 GB to 268 GB of memory footprint. Swap reached 76 GB.\n\n### \n  Why the guard missed it\n\nThe guard's rules were written around a real fear: killing an agent while you are using it. So the rule was simple. If a process belongs to a live agent session, leave it alone. That protects a Claude or Codex session that is working hard on a big build.\n\nThe same rule also protects a process that is eating the machine. A node helper is a child of the agent, so it inherited the agent's immunity. The guard was doing exactly what it was told to do. The rule was wrong, not the code.\n\n### \n  What we changed\n\nNow, when macOS reports critical memory pressure and one process holds at least half of the machine's RAM (never less than 16 GB), the guard stops that process, even under a live agent session. It sends SIGTERM first. If the same process is still running after 3 seconds, it sends SIGKILL.\n\nThe check is one pure function:\n\n``` js\nconst RUNAWAY_MIN_MB = 16 * 1024;\nconst RUNAWAY_RAM_SHARE = 0.5;\n\nfunction findMemoryRunaways(procs, footprints, { level, ramMB } = {}) {\n  if (level !== 'critical' || !ramMB) return [];\n  const fp = footprints || new Map();\n  const limitMB = Math.max(RUNAWAY_MIN_MB, ramMB * RUNAWAY_RAM_SHARE);\n  return procs\n    .filter((p) => {\n      const mb = fp.get(p.pid);\n      if (!(mb >= limitMB) || p.pid < 100) return false;\n      // ...then the spared cases below: system paths, Jamf, VMs, app executables\n      return true;\n    })\n    // (excerpt, trimmed)\n}\n```\n\nThe real function has more conditions in that filter, and those matter as much as the threshold. It never stops system processes, Jamf, an app's own executable, or browser helpers. It also spares virtual machine and local model runners such as qemu, ollama and llama-server, plus databases like postgres and redis. Runtimes (node, python, bun, deno, ruby, java) count wherever they run.\n\nOne bug showed up while testing. App paths can contain spaces, as in \"Google Chrome.app\", and my first version missed them. The fix reads the executable path until a space is followed by an argument that starts with a slash or a dash. The new table test includes a path with a space so it stays fixed.\n\n### \n  Check this on your own machine\n\n1. Look at your own guard or cleanup script. Does it have an exemption for processes owned by an agent, an editor or a terminal? Ask what happens when the exempt process is the one that leaks.\n2. Look at swap during a heavy session with `sysctl vm.swapusage` . Swap in the tens of gigabytes means you are already in trouble, even if free memory looks fine.\n3. Find the biggest process by footprint, not resident size: `top -l 1 -o mem -n 5` . A leaking helper shows up there before the system warns you.\n\nAn exemption that protects your work should have a ceiling. A process using half the machine is not doing your work anymore, whoever started it.\n\nThe guard is open source. The code for this change, the incident fixture and the tests are in the repo: [https://github.com/IgorGanapolsky/mac-yolo-safeguards](https://github.com/IgorGanapolsky/mac-yolo-safeguards)", "url": "https://wpnews.pro/news/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it", "canonical_source": "https://dev.to/igorganapolsky/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it-trusted-the-agent-3dbd", "published_at": "2026-11-17 15:06:29+00:00", "updated_at": "2026-11-17 20:18:08.202742+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Claude Code", "Codex", "Jamf", "ollama", "llama-server", "qemu", "postgres", "IgorGanapolsky/mac-yolo-safeguards"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it", "markdown": "https://wpnews.pro/news/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it.md", "text": "https://wpnews.pro/news/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it.txt", "jsonld": "https://wpnews.pro/news/my-memory-guard-watched-one-process-grow-to-268-gb-and-did-nothing-because-it.jsonld"}}