How-to Resources
Find a runaway process before your Mac locks up
A test that starts processes in a loop, or an agent that runs too many jobs, can fill the process limit of your user. Then the Mac stops to respond, and you cannot open Terminal to stop the job. This guide shows how to check the three limits that usually cause this.
The process limit
macOS gives each user a maximum number of processes. Show the limit:
sysctl kern.maxprocperuid
Count your processes now:
ps -U "$USER" -o pid= | wc -l
If the count is near the limit, find the parent that starts the most processes:
ps -U "$USER" -o ppid= | sort | uniq -c | sort -rn | head -5
The first column is the count of children. The second column is the process ID of the parent. Ignore parent 1: it is launchd, which starts the apps of macOS. Show a different parent:
ps -o pid,command -p <ppid>
Caution: Stop only a process that you know. Stop it with
kill <pid>first. Usekill -9only when the process does not stop.
The memory pressure
The memory pressure tells you if macOS has sufficient memory. Run:
memory_pressure | tail -1
The line shows the free memory of the system as a percentage. A low value means high pressure.
You can also open Activity Monitor › Memory and look at the Memory Pressure chart. Green is normal. Yellow and red mean that macOS must compress memory or write it to disk.
The free disk
A full start disk can also stop the Mac. Show the free space:
df -h /
With Widgetful
Widgetful watches these three values all the time, from the menu bar:
- Memory pressure from macOS: normal, warn or critical.
- Your process count against the macOS limit.
- Free space on the start disk.
Before a value gets to its limit, the icon turns red and the panel shows the reason. The Resources page shows a chart of the last 10 minutes for each value. The app keeps these values in memory only.