Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

24 Hours of Zero Posts: The 46GB Compressed-Memory Bomb That RSS Couldn't See

Description and use

A launchd script automatically detects and kills memory‑hungry background processes, preventing Playwright timeouts and ensuring continuous social media posting.

Problem

Automated social media posting stopped after 24 hours due to hidden memory pressure from compressed pages, causing Playwright to timeout.

Outcome

The launchd job automatically detects and kills memory‑hungry background processes, preventing silent crashes and ensuring continuous social media posting.

Workflow

  • 1. Configure launchd to run a shell script every 10 minutes with low priority.
  • 2. Use top -l 1 -n 20 -o mem -stats pid,command,mem,cmprs to fetch MEM and CMPRS values.
  • 3. Convert human‑readable memory units to MB with a to_mb() function.
  • 4. If MEM or CMPRS exceeds thresholds, kill the process with sudo -n killall <process> and allow launchd to restart it.
  • 5. For iii, send SIGTERM, wait, then SIGKILL and run kickstart -k to clean orphaned memory.
  • 6. Run a separate CPU scan with ps -Aco pid, %cpu, comm to detect high CPU usage; restart if threshold sustained.
  • 7. Log actions, enforce a 30‑minute cooldown per process, and send a Discord notification with current swap usage.
  • 8. Use shlock to prevent concurrent script executions.
  • 9. Exclude critical system processes via a NEVER_TOUCH list.
  • 10. Tune thresholds via environment variables in the launchd plist.

Evidence

dasd: MEM=47G/CMPRS=46G → 閾値3072MB超

Source

killall iii → launchd immediately restart the parent process (node)

Source

  • Record date: 2026-09-08T22:01:36.259Z