Skip to content

Repository files navigation

MacOS_Process_Monitor

The Process Monitor menu

A tiny macOS menu bar app that shows the number of processes owned by the current user and notifies when the count climbs past 85% of kern.maxprocperuid — the limit that, once hit, causes fork() to start returning EAGAIN and breaks terminals, browsers, and most apps.

Mirrors ps -u $USER | wc -l exactly so the menu bar number matches what you see in a shell.

What the menu bar shows

The status item shows your per-UID process count against the cap. The default is text — <count>/<limit> (<pct>%) in monospaced digits — but the Display submenu offers seven configurations: three text and four custom-drawn icons.

Mode displayMode Menu bar
Count / limit / pct (default) countTotalPct count limit pct
Count / limit countTotal count limit
Percent percent percent
Gauge (needle) gauge gauge
Arc arc arc
Pie pie pie
Wedge wedge wedge

Severity is colour-coded on the icon modes — green < 50%, orange < 85%, red ≥ 85% — and the text modes turn red at/above the 85% threshold:

30% (green) 70% (orange) 90% (red) text ≥ 85%
green orange red text warning

The threshold notification has a 5pt hysteresis so a single bounce around the limit doesn't spam alerts.

Click the icon for:

  • Sparkline of the recent count history.
  • Crash-looping submenu — names caught by the respawn-loop detector (shown only when there's something to report).
  • Top spawners submenu — the processes spawning the most children; click an entry to open a floating detail window for it.
  • Open Activity Monitor (⌘A).
  • Start at Login toggle.
  • Quit (⌘Q).

The detail window auto-refreshes every 2s while open and has a manual Refresh button. There is no "Refresh now" in the main menu — the 5s polling loop makes it redundant.

Build

Requires Xcode command line tools (Swift 5.9+, macOS 13+).

./scripts/build-app.sh

Produces build/ProcessMonitor.app. The script wraps the Swift Package Manager binary in a .app bundle and ad-hoc codesigns it — the signature is required, because UNUserNotificationCenter silently drops notification requests from unsigned bundles and threshold alerts won't fire.

Run

open ~/Applications/ProcessMonitor.app

~/Applications/ProcessMonitor.app is a symlink to build/ProcessMonitor.app, so rebuilds propagate without re-copying. The icon appears in the menu bar (no Dock icon — LSUIElement is set).

On first launch macOS will ask for notification permission. Approve it, otherwise the threshold alert can't fire.

Configuration

Tunables live at the top of Sources/ProcessMonitor/main.swift:

  • warnPct — threshold in percent (default 85)
  • pollSeconds — refresh interval in seconds (default 5)

Rebuild after changing.

Start at login (optional)

Use the Start at Login toggle in the menu. It registers the app via SMAppService.mainApp (bundle-ID based) rather than a LaunchAgent — macOS manages the lifecycle, and the app must live in /Applications or ~/Applications for registration to be accepted (which is what the ~/Applications symlink above provides).

Alternatively, add the app under System Settings → General → Login Items ("Open at Login"). Use one method, not both, or it may launch twice at login.

The menu-bar suite

Part of a suite of macOS menu-bar apps that share one framework, one build-and-sign script, and one installer. They are designed to sit in the same bar together: consistent menus, a common Icon picker for shape and colour, and cooperative hiding so no icon strands another.

App What it does
Claude Usage Claude Code plan limits, resets, and live agent sessions
Apollo Monitor Universal Audio Apollo monitor level, plus a UA process watchdog
Battery Time Time remaining, power mode, and 24h usage
VPN & DNS One dot for Mullvad + Tailscale state, with a DNS watcher
Process Monitor Process-count sparkline against the per-UID limit
KeyLight Ctrl+brightness keys remapped to keyboard backlight
MacRecorder Screen recording with system audio
Media Tracking Killer Kills Apple's media tracking daemons
Download Recycler Sweeps stale files out of ~/Downloads
Curtain Hides a block of status icons by width, so it cannot strand one
Framework
StatusItemKit Status-item lifecycle, polling, menus, meter icons, the shared Icon picker
HotkeyKit CGEventTap engine for intercepting and remapping global keys

Install the whole suite on a fresh Mac with macOS Dev Environment Setup:

git clone https://github.com/nicholaspsmith/MacOS-Dev-Environment-Setup.git
cd MacOS-Dev-Environment-Setup && ./bootstrap.sh --all

About

A taskbar app for tracking active processes in MacOS to prevent hitting per-UID process limit

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages