A tiny native macOS utility written in SwiftUI that watches for processes with sustained, abnormally high CPU usage and lets you terminate them — manually or automatically.
If you spend time in Activity Monitor, you have probably seen a process stick at over 100% CPU for a long stretch. Most of the time that is not normal multi-core work; it is a hung or buggy process spinning in an internal loop. Keeping it alive burns battery, generates heat, and serves no purpose. This tool detects that exact pattern — CPU above a threshold you choose, for a duration you choose — and either lists the offender or kills it for you.
- Samples all processes every 3 seconds using the system
topcommand. - Flags any process whose CPU usage stays above your threshold long enough.
- Shows flagged processes in a live table with PID, name, owner, CPU %, and how long it has been high.
- Provides an Auto-kill toggle:
- Off: you review the list and click Force Quit yourself.
- On: the app runs
kill -9automatically as soon as a process qualifies.
- For processes owned by other users (e.g. root/system daemons), a normal
killis attempted first; if that fails, it escalates viaosascriptwith administrator privileges. - Remembers your threshold, duration, and auto-kill choice in
UserDefaultsso they survive restarts.
cd ~/dev/mac-process-health-monitor
swift build -c releaseA bare SPM executable does not get a Dock icon or window from the system. Wrap it as an .app:
cd ~/dev/mac-process-health-monitor
rm -rf MacProcessHealthMonitor.app
mkdir -p MacProcessHealthMonitor.app/Contents/MacOS
mkdir -p MacProcessHealthMonitor.app/Contents/Resources
cp .build/release/MacProcessHealthMonitor MacProcessHealthMonitor.app/Contents/MacOS/
codesign --force --deep --sign - MacProcessHealthMonitor.appThe Info.plist bundled in this repo is used automatically.
open MacProcessHealthMonitor.appOr double-click MacProcessHealthMonitor.app in Finder.
Because the app is only ad-hoc signed and not notarized, macOS may refuse to open it the first time. If you see a "cannot be opened" dialog, run:
xattr -cr MacProcessHealthMonitor.app
open MacProcessHealthMonitor.appOr go to System Settings → Privacy & Security and click Open Anyway.
- Auto-kill is off by default.
- The app never targets itself or the kernel task (
kernel_task, PID 0). - Killing root-owned processes triggers a system password prompt via
osascript; the app never stores or handles passwords itself. - Use sensible thresholds. Some legitimate workloads briefly spike above 100% CPU on multi-core machines; that is why the tool cares about sustained usage, not single-sample bursts.
MacProcessHealthMonitor/
├── Package.swift
├── README.md
├── MacProcessHealthMonitor.app/ # bundled after build
│ └── Contents/
│ ├── Info.plist
│ └── MacOS/MacProcessHealthMonitor
└── Sources/MacProcessHealthMonitor/
├── MacProcessHealthMonitorApp.swift
├── ContentView.swift
├── ProcessMonitor.swift
└── ProcessInfo.swift
MIT