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

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

说明与用途

launchd 脚本自动检测并终止占用过多内存的后台进程,防止 Playwright 超时,确保社交媒体持续发布。

问题

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

结果

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

工作流

  • 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.

证据

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

来源

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

来源

  • 记录日期: 2026-09-08T22:01:36.259Z