OK I think I actually figured this out and you are all wrong including OP ?
Pretty close, but we disagree on whether or not Cached Files counts as 'used' (MacOS counts it under the applications that are running, so I say they get the tie-breaker), and about whether Swap should be counted as used (again MacOS says it is and when you're swapping, you certainly will agree).
Note, if you're not adding up the "Memory" and "Compressed Memory" columns in Activity Monitor, you're not seeing the actual memory your currently running processes have/want/are tracking (not all of it will be in RAM).
You can confirm these values by running the following command:
top -l 1 -S -n 0
Here's the results from about the same time my other screenshots were taken:
Notice that:
- All 16gb of physical memory is used (all but 141mb)
- Another ~6.2gb of memory has been swapped to disk
That's right in line with the 21.8gb of memory shown when I added up all the values in the "Memory" column in Activity monitor.
Say it together now: my apps were using 22gb of memory. This includes some of the memory that the memory manager flags as 'cached' (can be dumped). See below...
Cache Used is 2.33 GB = Physical Memory - Memory Used. Watch as the figures change - Memory used + cache = Physical memory maybe off by 0.1 at most. The OS is leaving recently used stuff in 'cache memory' in case it needs it soon. But it will drop this instantly if needed by something more urgent. So you 16GB is always being fully used and stuff in cache just gets overwritten when no longer needed.
Yes, Cached Files is memory apps are no longer actively holding onto, and is available to be dumped, and if it IS dumped, must be reloaded from disk.
Suggesting this is not 'used' is not exactly correct. It contains data that actively running apps (or recently run apps) can directly access if they need again. For example, closing a safari window will not dump it from Cached Files, and if you undo that tab close, it will be there without reloading.
Now for recently closed apps, I might almost agree that it's not 'really really' used, but for still running apps, I'd argue it is actually used. Or at least still useful. And both types (still running more than recently running) are still going to be speeding up your mac (the reason MacOS does it), which is a more relevant criteria for this particular discussion on memory management and performance.
More importantly, MacOS accounts for this as memory used, so it gets the tiebreaker.
If you add all that up its actually close to 40GB - my SSD was also basically full at this point and so swap space was limited. I can tell you everything ground to a halt and my machine was basically an expensive stylish heater until I shut down all these process.
40gb is a lot! But you got there. Your machine ground to a halt and no amount of extra CPU/GPU would have helped that.
Of course with 64gb of ram your machine would still have been screaming fast. <<<---MY POINT.
@MrTemple Your machine was actually using 12GB physical RAM + 6GB swap space making about 18GB. The cache should not be counted (its probably copied in the swap space in fact). Even with that the swap space probably shouldn't be counted either because unless you have maxxed out your physical space like I did - its not data that is needed super urgently.
Well, the cached memory is there for a reason, it makes your Mac faster. (And MacOS is reporting all 22gb as used) This 'Cached Files' memory is part of the incredibly good memory management intelligence which MacOS uses to mitigate smaller amounts of ram than your processes are requesting.
As for the swap, you may not need it 'super urgently' I agree, but we both agree that having it in-RAM instead of on-disk is going to speed your Mac once again.
TL;DR: Dollars in RAM often improve performance, more than dollars into more CPU/GPU.