Compressed memory on a Mac, explained
Compressed memory is macOS shrinking data that apps are not using right now so it takes less room in RAM. Instead of pushing that data out to the disk, the Mac squeezes it into a smaller space in memory and expands it again when the app needs it. A large compressed figure is normal and usually harmless. It only tells you something when it grows together with memory pressure.
If you have seen a big “Compressed” number and wondered whether your Mac is in trouble, the short answer is that it almost never is on its own.
What it is
Your Mac has a fixed amount of RAM. Apps fill it with two kinds of data: things they are actively using, and things they loaded earlier and have not touched for a while, such as a document in a tab you opened an hour ago. The second kind still has to be kept, because you might come back to it.
When RAM runs short, macOS has a choice. It can write the idle data out to the disk, which is slow to do and slow to read back. Or it can compress it: the same data, held in memory in less space. Compressing and expanding take a moment of processor time, but that is far quicker than a trip to the disk, and it keeps the disk out of it.
So compression comes first. Only when compressing is not enough does the Mac start using the disk, which is swap. Is your Mac using swap? What it means and when to worry covers that second stage.
Why a large figure is good news, not bad
The number looks alarming because it sounds like something is wrong. It is the reverse. A Mac with a lot of compressed memory is a Mac using its RAM for what it is for: keeping lots of things ready, instead of writing them out.
Free memory is not a goal. RAM that nothing is using is wasted, so macOS fills it, and then reclaims it as needed. A Mac that shows almost no free memory and a healthy amount of compressed data is working as designed. Why does my Mac use so much memory with nothing open goes into how that looks in practice.
See it for yourself
The built-in way is Terminal. Run vm_stat. It prints counters for memory, in pages, and states the page size on its first line (16384 bytes on Apple silicon, 4096 on Intel Macs). Two lines are the ones to find:
- Pages stored in compressor: how many pages of data have been compressed.
- Pages occupied by compressor: how many pages that compressed data takes up now.
The second is smaller than the first, and the gap is the saving. Multiply the page counts by the page size to get bytes, then divide to get gigabytes. For example, a million pages stored in a space of a third of a million is the compression doing its job.
Run memory_pressure for a summary of how the Mac is doing, including the free percentage. Typed on its own, with no options, it only reads and reports. (With options, the same tool can put the Mac under memory pressure on purpose for testing, so do not add any.)
When it does signal pressure
Compressed memory by itself is not the signal. Look at what it is doing over time.
It grows and stays large while the Mac is slow. If the compressed amount keeps climbing, and apps pause when you switch to them, the Mac is working hard to make room. Each time you return to an app, the Mac has to expand its data, and that costs a short wait.
Memory pressure rises and stays high. Memory pressure is the measure that matters, because it takes into account how hard the Mac is working to find room, not just how much is used. Low pressure means the Mac is coping with room to spare; pressure that stays high through your normal work means it is short of memory. Memory pressure on a Mac: when you actually need more RAM is the post to read on this.
Swap starts to climb alongside. Once compression is not enough, the Mac starts using the disk. Compression, then swap, in that order, is a sign of a Mac that is short of memory.
If none of those is true, a large compressed number is just a Mac using its memory well.
What to do when the signs are there
Start with the biggest memory user, not with the compressed figure. Foreman’s Processes page has a Memory column you can sort, with the Mac’s total above it, and its Performance page shows Memory with memory pressure and the apps using the most. Foreman does not free memory, and tools that promise to free RAM mostly push out data the Mac then has to load again.
What helps is simple:
- Quit apps you are not using. Closing an app is the one way to give its memory back for good.
- Close browser tabs and windows. A browser is often the biggest single user, because each tab can run as its own process.
- Restart an app that has grown over days. Some apps hold on to more and more memory the longer they stay open, and a restart returns it. Foreman’s Restart quits the app and opens it again behind Foreman, so you stay where you were.
- Choose more RAM when you buy your next Mac, if memory pressure is regularly high with your normal work. On a Mac with Apple silicon the memory is built in and cannot be added later. How much memory does a Mac really need helps you choose.
Do not try to reduce the compressed figure for its own sake. It will rise again as soon as you use the Mac.
Is compression slowing my Mac?
Compressing and expanding data uses the processor, and on a Mac that is short of memory it can add up. Much of that work is done by macOS itself rather than inside the app whose data it is, so it does not show up clearly against any one app. This is part of why a Mac that is short of RAM feels slow even when no app has a high CPU figure. The fix is the same: lower the memory demand, and the compression work falls.
On a Mac with enough RAM it is invisible. You will not see a slowdown from it, and you do not need to do anything.
The short version
Compressed memory is a first step the Mac takes before it uses the disk. A big number is normal. Check memory pressure and swap, not the compressed figure, to decide whether to act. Foreman is $12 once and free for 24 hours if you want the Memory column and memory pressure on screen, and vm_stat and memory_pressure give you the rest for free.