My 16 GB MacBook kept beach-balling with a pile of tabs open. Activity Monitor gave me numbers, but it never told me what was wrong or what to do about it. So I made BerryStat, a menu bar app that says it plainly ("Memory is tight. Chrome uses the most: 6.4 GB") and, when memory runs short, slows the apps busy in the background so the one I'm using stays quick.

Here is how the slowing works, and the parts that went wrong on the way.

Slowing: macOS's background band

macOS already has a way to say "this process can wait": the background band, the same one Time Machine runs in.

setpriority(PRIO_DARWIN_PROCESS, id_t(pid), PRIO_DARWIN_BG) // slow setpriority(PRIO_DARWIN_PROCESS, id_t(pid), 0) // let go 

On Apple silicon a process in the band runs only on the efficiency cores, and its disk and network work goes to the back of the queue. Nothing breaks: the app keeps working, more slowly. No root is needed, because macOS lets you do this to your own processes.

BerryStat slows an app when memory runs short (or the Mac runs hot) and the app has used at least half a core in the background for 10 seconds. A short burst of work is left alone. It never slows the app in front, or one playing or recording sound, like a call or music. It lets go a minute after the Mac recovers, one app every 15 seconds.

An app is many processes

Chrome with a few tabs is dozens of processes. Slowing only the main one does nothing, so BerryStat groups processes by the .app bundle they run from, and holds back every one of them, helpers that start later included. Some helpers are XPC services that live outside the app's bundle (WebKit's, for one). For those it asks macOS which app is responsible for them, through responsibility_get_pid_responsible_for_pid, a private function looked up with dlsym, so it can count them toward the right app.

When memory runs out: pausing in beats

Slowing doesn't free memory. When macOS reports memory as critical, BerryStat also pauses the biggest background apps (500 MB or more, at most three) with SIGSTOP, so they stop asking for more.

My first version stopped them outright. That hung everything waiting on them: a page served by a dev server, a database in Docker, a file in a cloud drive's folder. Their network connections dropped too. Now a paused app runs in beats: four seconds stopped, one second running (SIGCONT). It answers late instead of never.

Two more rules came from mistakes. A command you typed in a terminal is never paused: it has its own process group, and stopping it makes the shell print "suspended" and take the prompt back, as if you'd pressed Ctrl-Z. And a process someone else stopped (a debugger, say) is theirs to let go, not BerryStat's.

If BerryStat dies while holding something

A stopped app stays stopped if the app that stopped it crashes. So while anything is held, BerryStat runs a small watchdog next to it:

while kill -0 $BERRYSTAT_PID 2>/dev/null; do sleep 1; done kill -CONT 1234 5678 2>/dev/null /usr/sbin/taskpolicy -B -p 1234 2>/dev/null 

If BerryStat crashes or is force quit, everything gets full speed back within a second or two.

Why it isn't on the Mac App Store

The App Store sandbox doesn't let an app list other apps' processes or signal them, which is all of the above. So BerryStat is sold on its own site, signed and notarized by Apple.

What it can't do

It can't add memory. If yours runs out every day, its alerts will make that plain, and the honest fix is fewer open apps or a Mac with more memory. It deletes nothing and never quits an app unless you click Quit and confirm.

BerryStat is $14.99 once, with 14 days free and no card, for Apple silicon Macs on macOS 15 or later: https://berrystat.com. This launch week it's 30% off with the code LAUNCH30, through December 6.

I'd like to hear where the slowing helps and where it gets in the way.