Mac Performance Guide
High swap usage on Mac: when it matters
Short answer
Swap is memory macOS has moved out of RAM into files on the disk. It compresses memory first and swaps when that is not enough. A big "swap used" number on its own is mostly history: pages that went out once and have not been needed since. It matters when the Mac is still swapping while you work and memory pressure is yellow or red.
Check it from the terminal
How much swap exists and how much is in use:
sysctl vm.swapusage
vm.swapusage: total = 23552.00M used = 22390.50M free = 1161.50M (encrypted)
That looks alarming, but on the same 48 GB Mac, at the same moment, the pressure level was normal:
sysctl kern.memorystatus_vm_pressure_level
kern.memorystatus_vm_pressure_level: 1
The real question is whether swapping is happening now. vm_stat with an interval prints the totals since boot, then the change every 5 seconds; the last two columns are pages swapped in and out:
vm_stat -c 4 5 | awk 'NR>1 {print $(NF-1), $NF}'
swapins swapouts
59644228 72764583
8 0
8 0
1354 0
Zero swapouts and a few swapins is a quiet Mac. Thousands of pages in both columns, row after row, is a Mac that is short of memory for what you are doing. The swap files themselves live in /System/Volumes/VM; macOS adds them as swap grows and removes them when it can.
What to do about it
If swap is high but pressure is green and vm_stat is quiet, you can ignore it. If not, the causes and fixes are the same as for memory pressure, covered in Mac memory pressure yellow/red. For swap in particular:
- Quitting an app frees all of its memory, including the part in swap. An app whose memory keeps climbing for days is the usual culprit.
- A restart starts over with no swap in use.
- Keep free disk space. Swap files need room to grow, and when they cannot, macOS shows "Your system has run out of application memory" and asks you to quit apps.
The easier way: GaugeMon
GaugeMon's Memory gauge sits in the menu bar and can change colour when it is high. Click it for app, wired, compressed and cached memory and swap, with a chart picker for used memory, swap or pressure over the last 10 minutes, so you can see whether swap is climbing now or just left over from earlier.