Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Zelda Chestnut

macrumors member
Original poster
Dec 4, 2018
74
40
I am just curious about something. I am looking at Activity Monitor, and I have 16 gb of RAM, or Physical Memory as it's called. Then I see the break outs of Memory Used, Cached Files, and Swap Used. Memory Used and Cached Files amounted to a higher total than the 16 gb available. How is that possible? Is there overlap in those two metrics? Thanks!
 
Memory Used and Cached Files amounted to a higher total than the 16 gb available.
How much higher? And consistently or just fleetingly?

First of all, there is usually some Free memory so that Used+Cached < Physical. So you must have no free memory. Is your memory pressure low?

On my Mac (when the free memory is very close to zero), the difference is usually a few 0.01 GB either way, some times 0.1 GB. I put this down to a) rounding errors, b) slight differences in measurement times (memory usage is very dynamic), and c) lack of any clarity about how the numbers are produced from underlying counters (particularly App Memory).

You get a different and more detailed (incomprehensible?) breakdown from the Terminal command vm_stat which presents some counters directly from the memory management parts of the kernel.

When it comes to memory, the simplest of questions requires complex answers.
 
Last edited:
  • Like
Reactions: Brian33
I am just curious about something. I am looking at Activity Monitor, and I have 16 gb of RAM, or Physical Memory as it's called. Then I see the break outs of Memory Used, Cached Files, and Swap Used. Memory Used and Cached Files amounted to a higher total than the 16 gb available. How is that possible? Is there overlap in those two metrics? Thanks!
First off, there are rounding errors. Then we have to remember that a gigabyte is 1,048,576 bytes, not 1,000,000 bytes. (unless you are selling disk drives, then the term "gb" is abused to means 1,000,000)

So on your computer, there are 16,777,216 bytes of physical RAM
 
Then we have to remember that a gigabyte is 1,048,576 bytes,
My calculation is 1GB of RAM is 1,073,741,824 bytes, so 16GB of RAM is 17,179,869,184 bytes. And always abbreviated to GB, never gb.

SI or IEC rules say that 1GB is 10^9 bytes and 1 GiB is 2^30 bytes. It is RAM specs which "abuse" the standard. Or you could say that RAM specs predate (I remember 1 kB boards) the GiB/GB distinction introduced in 1998.
 
Last edited:
My calculation is 1GB of RAM is 1,073,741,824 bytes, so 16GB of RAM is 17,179,869,184 bytes. And always abbreviated to GB, never gb.

SI or IEC rules say that 1GB is 10^9 bytes and 1 GiB is 2^30 bytes. It is RAM specs which "abuse" the standard. Or you could say that RAM specs predate (I remember 1 kB boards) the GiB/GB distinction introduced in 1998.
Yes, I got the math wrong. Apple uses "GB" only, so as not to confuse people. So 1GB is more than 10^9. THey do use a footnote to tell you that GB = 10^9 for storage but the footnote seems to be missing for RAM. This is common industry usage.
 
I don't remember exactly, but it wasn't a huge amount over 16 gb, so then maybe it was just a rounding error! It's not a big deal, I was just curious. Thanks everyone!
 
Ok, a little follow up here: I just looked again and it said 12.80 memory used and 5.14 cached files. That's 17.94 overall RAM. Can the rounding errors be that far off?
 
I just looked again and it said 12.80 memory used and 5.14 cached files. That's 17.94 overall RAM. Can the rounding errors be that far off?
That is not a rounding error.

I just caught Activity Monitor on my Intel Mac showing Memory Used + Cache as 1GB more than physical! But at that moment App + Wired + Compressed was 1GB less than Used Memory. In other words App + Wired + Compressed + Cache + negligible Free does equal Physical. The difference seems to be tied up with how Memory Used is calculated - it is NOT (as I had always supposed) just the sum of App + Wired + Compressed.

Whilst I wrote the last paragraph the difference/error has remained at 1GB plus or minus about 0.1GB.

From vm_stat output I can calculate:
App Memory: 32.640 GiB Wired Memory: 6.694 GiB Compressor: 4.120 GiB Memory Used: 43.454 GiB (sum of 3 above, whilst Activity Monitor says ~1GB more) Cached Files: 52.462 GiB Free Memory: 0.081 GiB Total: 95.997 GiB

And that seems to be correct (within a very small margin) for my physical RAM. It is Activity Monitor's "Memory Used" which seems to be wrong or, should I say, calculated differently.
 
Last edited:
Interesting! Yeah, I am wondering if there are certain numbers that are double-counted or something. I am also curious if there is a difference between Intel and M-series Macs, as I have an M2 Mac Mini.
 
I am wondering if there are certain numbers that are double-counted or something. I am also curious if there is a difference between Intel and M-series Macs, as I have an M2 Mac Mini.
Mine is 2019 iMac - Intel. So I don't think this is an Intel/ASi difference. Whilst physical connection to memory is somewhat different, I believe that memory management (apart from page size and some tuning) is the same - and indeed the same as in iOS, etc.

State of documentation:
1) Activity Monitor's help has some nonsense in it, e.g. "App Memory: The app could not be installed".
2) As far as I can see, the Apple Developer documentation is aimed at developers understanding the memory behaviour of their apps, not the system as a whole.
3) man vm_stat is dated 1997 and certainly does not describe all the output of vm_stat.
4) man sysctl is dated 2011 and does not mention sysctl vm.
5) Non-Apple: Mac OS X and iOS Internals (2013) and *OS Internals Vol II (2019) by Jonathan Levin are too detailed for me!

Using the output of vm_stat, you can get two views of memory statistics. The first view is of the "traditional" Unix counters (free, active, inactive, speculative, throttled, and wired along with pages occupied by the compressor) which do add up to physical RAM. Secondly, with a bit of guesswork/interpretation, the Activity Monitor counters can also be reproduced.

In Activity Monitor:
A) App+Wired+Compressed+Cached does add to Physical Memory less what is in Free Memory (you can only get that vm_stat). That seems to be consistently correct.
B) App+Wired+Compressed is greater (usually be a small amount) than Memory Used. This is even though the style of the display suggests that they do add up.
C) Not showing Free Memory hides the facts that Memory Used + Cached + Free Memory is greater than Physical Memory.
d) When Free Memory is very small, you can get Memory Used + Cached greater than Physical Memory. This is what you are seeing.

I suspect that the error is due to Activity Monitor counting vm_stat's Pages Purgeable into both Memory Used and Cached Files. But I need to explore that further.

If you do look at the output of vm_stat, do be aware that the numbers are in pages where a page is 4096 bytes (Intel) or 16,384 (ASi). And that memory as GB, is where a GB is 2^30 bytes, not 10^9 bytes.
 
  • Like
Reactions: Brian33 and chown33
Mine is 2019 iMac - Intel. So I don't think this is an Intel/ASi difference. Whilst physical connection to memory is somewhat different, I believe that memory management (apart from page size and some tuning) is the same - and indeed the same as in iOS, etc.

State of documentation:
1) Activity Monitor's help has some nonsense in it, e.g. "App Memory: The app could not be installed".
2) As far as I can see, the Apple Developer documentation is aimed at developers understanding the memory behaviour of their apps, not the system as a whole.
3) man vm_stat is dated 1997 and certainly does not describe all the output of vm_stat.
4) man sysctl is dated 2011 and does not mention sysctl vm.
5) Non-Apple: Mac OS X and iOS Internals (2013) and *OS Internals Vol II (2019) by Jonathan Levin are too detailed for me!

Using the output of vm_stat, you can get two views of memory statistics. The first view is of the "traditional" Unix counters (free, active, inactive, speculative, throttled, and wired along with pages occupied by the compressor) which do add up to physical RAM. Secondly, with a bit of guesswork/interpretation, the Activity Monitor counters can also be reproduced.

In Activity Monitor:
A) App+Wired+Compressed+Cached does add to Physical Memory less what is in Free Memory (you can only get that vm_stat). That seems to be consistently correct.
B) App+Wired+Compressed is greater (usually be a small amount) than Memory Used. This is even though the style of the display suggests that they do add up.
C) Not showing Free Memory hides the facts that Memory Used + Cached + Free Memory is greater than Physical Memory.
d) When Free Memory is very small, you can get Memory Used + Cached greater than Physical Memory. This is what you are seeing.

I suspect that the error is due to Activity Monitor counting vm_stat's Pages Purgeable into both Memory Used and Cached Files. But I need to explore that further.

If you do look at the output of vm_stat, do be aware that the numbers are in pages where a page is 4096 bytes (Intel) or 16,384 (ASi). And that memory as GB, is where a GB is 2^30 bytes, not 10^9 bytes.
Thank you for the very detailed answered!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.