Menu

How my Mac menu bar app slows busy background apps, without root
📰

How my Mac menu bar app slows busy background apps, without root

DEV Community: swift·Morse Chimwai·6 days ago
#MNxn1JXo
#devtoswift#devto#dev#berrystat#runs
Long article (725 words) — no AI summary yet.
Reading 0:00
15s threshold

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

Enter fullscreen mode

Exit fullscreen mode

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

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.