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

MrTemple

macrumors 6502
Original poster
Jun 11, 2013
456
1,140
Canadian Pacific North Wilderness
Wait so now it’s 28GB?

Your numbers keep increasing.

Swapping memory is memory that's requested by apps. Part of the 22gb, as I've consistently said (and shown with screencaps) throughout this thread. Hard to know that if you don't read it though...

I should add - I was actually incorrect, if apples docs are correct. What it lists as “file cache” isn’t files in memory for active apps - it’s memory that was used by recently closed apps, kept around to make them reopen quicker, if needed.

So, even more so, not 22GB, not 28GB.

You're reading the doc wrong.

The cached memory is for 'files no longer being used by apps' including still-running apps AND no-longer-running apps (if there's sufficient memory overhead). The example they give is for a recently-closed app, but cached memory includes memory data allocated by running apps.

When that alleged "hit" begins to interfere with my work (which it hasn't).. then I'll worry. But, until then, I'm not going to allow your problem to become my problem.

Whose problem are you talking about?

This is a post about real-world performance benefits of new machine spec-upgrades. Often (for your use especially), bumping CPU results in a slower machine during actual use than if you'd put that money into RAM instead.

That's not a problem for anybody. It's just useful information to know when speccing out a new machine.
 

Stephen.R

Suspended
Nov 2, 2018
4,356
4,746
Thailand
cached memory
You realise that term is meaningless? It says cached files because it’s files stored in a faster location - memory.

What is cached memory? Memory stored in faster memory?

You're reading the doc wrong.
It literally says
Memory that was recently used by apps and is now available for use by other apps.

I’m done here. I’m as big a proponent of maxing ram as anyone but your insistence that you alone understand how memory works is getting old.
 

The Mercurian

macrumors 68020
Mar 17, 2012
2,153
2,440
OP is really overestimating the performance overhead of memory management. For example, compressing unused pages is essentially free. All you achieve by hoarding RAM is essentially decreasing your battery runtime and throwing more cache at your OS. Cache is always good of course, but there are diminishing returns. If the app switch animation takes longer than loading few hundred pages off the SSD, who cares where the cold pages lie exactly.
Hold on thou - compression is not completely free. An algorithm must run to compress and uncompress things - that must use up some CPU power.
 
  • Like
Reactions: MrTemple

revmacian

macrumors 68000
Oct 20, 2018
1,745
1,468
USA
This is a post about real-world performance benefits of new machine spec-upgrades. Often (for your use especially), bumping CPU results in a slower machine during actual use than if you'd put that money into RAM instead.

That's not a problem for anybody. It's just useful information to know when speccing out a new machine.
It's not useful information for someone who has spent the last decade building GNU/Linux machines and seems to be getting by rather comfortably doing a huge amount of office work on 8GB RAM. It is my opinion that what you're doing is encouraging people to waste money on RAM when they don't really need it.

But, to each their own.
 

MrTemple

macrumors 6502
Original poster
Jun 11, 2013
456
1,140
Canadian Pacific North Wilderness
Hold on thou - compression is not completely free. An algorithm must run to compress and uncompress things - that must use up some CPU power.

CPU power and extra time.

If a quarter or more of your memory in RAM is compressed, that adds up.

It's fast! Don't get me wrong.

But for multitaskers, it's going to be slower than a machine that put money into CPU instead of RAM.
[automerge]1574110642[/automerge]
It is my opinion that what you're doing is encouraging people to waste money on RAM when they don't really need it.

You aren't really reading.

My point is that IF you're going to put extra money into performance, you may not realize that you're Mac is managing limited RAM and is actually slowing down more than if you put money into RAM instead of CPU.
 

iPhysicist

macrumors 65816
Nov 9, 2009
1,343
1,004
Dresden
You know that rebooting is not a crime? You could also bookmark some of your webpages, as Safari seems to be you biggest memory hog. For most people the base config always is the best choice — memory, graphics and CPU as well as storage wise.
 
  • Haha
Reactions: MrTemple

Ries

macrumors 68020
Apr 21, 2007
2,316
2,829
You're wrong, you're presenting a cocked up use case that no average user even comes close to. I can have safari open with 10 tabs, xcode, lightroom and all the usual standard mac apps open and am still below 10GB of memory usage. And those apps are memory hogs. If you need more than 16GB you're already a user who is aware of it.

Screen Shot 2019-11-18 at 22.52.36.png
 

fathergll

macrumors 68000
Sep 3, 2014
1,788
1,487
And if you are dealing with spinning platters, it's still probably a good idea (i.e. Fusion Drive in the iMac).


I saw a big benefit from upgrading my RAM from 24GB to 32GB on my 2014 iMac recently which is using a 1TB fusion drive. If I was doing some heavy multitasking and using up 22GB of RAM before I could see my system starting to slow a bit but the upgrade to 32GB really solved that.

As far as maxing out a MBP with 64GB....tough to say. Obviously some people need to do it but the question is how long you are going to use this system. I'd say in 5 years that 64GB upgrade is going to start to seem like a good move.
 
  • Like
Reactions: MrTemple

gtg465x

macrumors 6502a
Sep 12, 2016
754
883
The OP is adding both Cached Files and Compressed to Memory Used, but I believe Cached Files and Compressed are subsets of (already included in) the Memory Used value.

In the OP's case, I believe his computer is using 12.33 GB of Physical Memory and has 16.00 - 12.33 = 3.67 GB of free physical memory. 3.6 GB (29%) of his used physical memory (12.33 GB) is Cached Files that don't really need to be loaded but are just there to improve performance in case those files are needed, and 1.02 GB (8%) of his used physical memory (12.33 GB) is Compressed. I believe the actual amount of memory his computer required at that moment was Memory Used (12.33) + Swap Used (6.04) - (minus since cached files aren't necessary) Cached Files (3.60) = 14.77 GB, not 22 GB.

Also, if you're wondering what memory pressure is and how it's calculated, I believe it is the percentage of physical memory being used that is actually required by the system and your running apps. As I mentioned before, Cached Files are just there to potentially improve performance in case they're needed at a later time, but they aren't currently needed and can be dropped from memory at any time, so memory pressure is (Memory Used - Cached Files) / (Physical Memory). In the case of OP, the memory pressure is (12.33 - 3.60) / 16.00 = 55%. If you look at his little memory pressure graph, you can see that it's about half full, which lines up with the 55% I just calculated.
 
Last edited:
  • Like
Reactions: miroki

raqball

macrumors 68020
Sep 11, 2016
2,323
9,573
Strange thread..

Guess my new 16" base (accoriding to the OP) with 16GB of RAM is ready for the scrap heap already, 3 days in!.. LOL
 
  • Like
Reactions: aimbdd

mightyjabba

macrumors 68000
Sep 25, 2014
1,586
328
Tatooine
Honestly sometimes I feel like threads like this is for someone who purchased a type of product and wants it justfied by poeple in here. In this case it backfired.
That sounds about right, although on the flipside there are people like me who want to believe that 16GB will be just fine for the life of the machine. So we all have our biases.
 

FlyingDutch

macrumors 65816
Aug 21, 2019
1,319
1,206
Eindhoven (NL)
With almost nothing running compared to my load use, I've got 22gb requested memory and swapping 6gb, and you're saying 32gb would be LESS useful than upgrading CPU/GPU?

Super savvy.

64gb is overkill now, but in 3-4 years? Not so much. (Which is why I say 32 is plenty if you're going to upgrade in a few years anyway).
your system isn’t requiring 22 giga. You are mixing things up.
And in 3 years nothing will change about memory usage.
For the above mentioned scenario, even 8 giga could be enough.
 
  • Haha
Reactions: MrTemple

The Mercurian

macrumors 68020
Mar 17, 2012
2,153
2,440
OK I think I actually figured this out and you are all wrong including OP ?

It's like this on my machine right now:

Screenshot 2019-11-19 at 01.17.49.png



So Physical memory is obvious - its 16GB machine.

Memory used - means active at the moment = 13.65 GB => made up of App memory 7.22 GB, Wired Memory 2.72 GB and Compressed memory - 3.71GB -> do the math it checks out - also the little dent in the vertical line is an arrow to show memory used is made up of these three things.

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.

Swap Used is the probably slightly older recently used data.

So presumably you only get into red memory pressure when your active programs need more memory than your Physical Memory. Then you will have major swap disking going on and your system grinds to a halt.
..... exhibit A:
Screenshot 2019-11-14 at 13.34.22.png


So right here - physical memory almost totally stuffed, so by necessity cached files is tiny and swap is huge. For this partciular moment this was in memory:

Screenshot 2019-11-14 at 13.35.05.png

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.


@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.
 
Last edited:

Ryan P

macrumors 6502
Aug 6, 2010
362
235
OK I think I actually figured this out and you are all wrong including OP ?

I believe you nailed it. Just for clarification, cached is when the operating system is loading files into memory for faster performance. Swap is when the memory is being dumped into physical files to free up memory.

That said I ordered 64GB, as i believe it will benefit my particular use case.
 
Last edited:

MrTemple

macrumors 6502
Original poster
Jun 11, 2013
456
1,140
Canadian Pacific North Wilderness
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:

Screen Shot 2019-11-18 at 9.13.49 PM.png


Notice that:
  1. All 16gb of physical memory is used (all but 141mb)
  2. 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.
 
Last edited:

leman

macrumors Core
Oct 14, 2008
19,200
19,060
Hold on thou - compression is not completely free. An algorithm must run to compress and uncompress things - that must use up some CPU power.

Apple uses a very very fast compression algorithm (WKdm) which they hand-coded in ridiculously optimises assembly (you can check out the details here, if you want https://opensource.apple.com/source/xnu/xnu-4570.1.46/osfmk/x86_64/). It is not that much slower than just reading the memory directly (we are talking maybe 4x-5x impact which is anything but major). Don't forget that loading a cold page is very slow in any case (we are talking about hundreds of CPU cycles) — decompression will help hide some of this latency (e.g. a page can be decompressed while the CPU is trying to fetch the next cold page from RAM).

Of course, all the above is jut my speculation and one needs to benchmark this to have a 100% reliable answer. But that is a hugely complicate undertaking. Personally, I doubt that there is that any noticeable performance difference between using compressed RAM and uncompressed RAM — provided we are talking about loading some sort of inactive data (e.g. switching to a deactivated app or such). If your actively used memory starts getting compressed, that is a different story, and then you really ought to get more RAM.
 

gtg465x

macrumors 6502a
Sep 12, 2016
754
883
OK I think I actually figured this out and you are all wrong including OP ?

It's like this on my machine right now:

View attachment 877945


So Physical memory is obvious - its 16GB machine.

Memory used - means active at the moment = 13.65 GB => made up of App memory 7.22 GB, Wired Memory 2.72 GB and Compressed memory - 3.71GB -> do the math it checks out - also the little dent in the vertical line is an arrow to show memory used is made up of these three things.

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.

Swap Used is the probably slightly older recently used data.

So presumably you only get into red memory pressure when your active programs need more memory than your Physical Memory. Then you will have major swap disking going on and your system grinds to a halt.
..... exhibit A:
View attachment 877947

So right here - physical memory almost totally stuffed, so by necessity cached files is tiny and swap is huge. For this partciular moment this was in memory:

View attachment 877948

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.


@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.

Cache is not Physical minus used. In some cases, like yours, the numbers do look like they’re lining up that way, but I’ve seen plenty of cases on my machine when they don’t come close to lining up. I think Cache is a subset of used, but it’s not in the little “App Memory, Wired Memory, Compressed” section because it’s probably a subset of App Memory and possibly Compressed as well. The fact that Memory Pressure lines up with (Used Memory - Cache) / Physical Memory proves that Cache is a subset of Used, not something separate.
 
  • Like
Reactions: MrTemple

kave

macrumors 6502a
Oct 31, 2012
535
277
Sweden
Interesting topic. It seems no one really reads the OT. The question was, should you upgrade CPU, GPU or RAM first. Which gives you more bang for the buck.
I would say the best thing is to keep an eye on the swap use, ie is the os swapping in and out memory very often in your use case. For most users it’s easiest to keep and eye on the current macs performance. If and when it starts to slow down, is it swapping? If it is, then buy more ram next time. If it is never, keep your current level.

Most users go by fine with 16GB, I use Premiere, Lightroom etc as well as Fusion with vms on my 2016 MBP with 16GB ram, but not at the same time. I have tried adding encodes in the background from Premiere but that renders my mac totally useless. Ie it swaps so hard it is unusable for anything. So I have to sit and wait for premiere to encode using 40-50% cpu because my ram is to low. Next Mac will have 32GB for this exact use case.
Now is it worth it, going from 16 to 32 is the same €€ as going from i7 to 2.4 i9. For someone who does use all ram like in my case above, the original poster is right.
But a user never using vms, can close apps when needing all the power you can for active work go with 16GB which is enough.
Now go from 16 to 64 is twice the price. I would say most important is not filling up the ssd, because that will truly make the mac slow.
Priority list:
Disk size
GPU
RAM
CPU
Do does everyone need 8TB and the best GPU? No, get the options you need.
But certainly the most limiting factor is a too small disk.
 

sat24

macrumors regular
Sep 2, 2019
230
146
Folks - swapping to 'disk' isnt as bad as it sounds, when u are talking about a super fast SSD 'drive' that is capable of 2GB/s transfer speeds. We are no longer (thankfully) in the days of 5400rpm disks when 'disk swapping' means u literally could hear the 'crunch, crunch' as the OS choked while waiting for a right sector on the right disk platter to spin under the disk drive head.

So in a nutshell - here's the simple way to think about it without over-analyzing it:

1) What is RAM? - get 16GB
2) I think I need more RAM - get 32GB
3) I know I need more RAM - get 64GB.

:)
 

leman

macrumors Core
Oct 14, 2008
19,200
19,060
So in a nutshell - here's the simple way to think about it without over-analyzing it:

1) What is RAM? - get 16GB
2) I think I need more RAM - get 32GB
3) I know I need more RAM - get 64GB.

:)

I'd actually put it like this.

1) I think I need more RAM - get 16GB
2) I know I need more RAM - get 32GB.
3) I will die without 64GB RAM - get an iMac Pro/Mac Pro, because if you want 64GB RAM, you also probably want quad memory channel, and that 64GB will eat through your battery in no time anyway.
 
  • Like
Reactions: 88Keys and raqball

workerbee

macrumors regular
Oct 26, 2006
174
89
Not disputing anything written here, but I admittedly find it hard to think of a scenario where more than 32GB RAM would in fact be really that useful, unless one needs to have multiple VMs of whatever kind open and running.
I'm thinking about getting a 32GB RAM 16", just to be on the safe side – our two 2012 rMBPs are both running very nicely, but the one with 8GB RAM has proven to be clearly less futureproof than the one with 16GB. On the other side, it's quite a steep price increase, and at the moment my 16GB present no problem whatsoever.

What I'd be quite curious to know: the OP claims that Apple's RAM optimization techniques are costing him in performance. I've never noticed anything of the kind, unless I ran into red Activity Monitor territory by opening every single app on the system (going out of disk space, on the other hand, can happen quite easily and quickly, and is extremely noticeable).

Are these purported RAM performance hits while still in the green quantified anywhere, in any tests, or is it a case of just feeling them because they somehow have to be there?

Bildschirmfoto 2019-11-19 um 08.11.53.png

Edit: I'be highly interested in numbers for "that 64GB will eat through your battery in no time anyway" as well – how much more battery power does 32 or 64GB RAM really use?
 

The Mercurian

macrumors 68020
Mar 17, 2012
2,153
2,440
<snip>

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).

Hold up now - does the Compressed Menu column show the physical memory used by compressed memory, OR the size of that memory when uncompressed ? I think its the later because on my machine the compressed memory for one item is bigger than allt he compressed memory down the bottom.

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:

View attachment 877967

Notice that:
  1. All 16gb of physical memory is used (all but 141mb)
  2. 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...

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.
You are not entirely correct in your interpretation. @Ryan P 's correction to my post above was correct (thanks Ryan P). The cache is loading up stuff that the OS thinks will be soon needed. But that memory would otherwise be sitting there charged up but doing nothing (you can't turn off RAM fully). The OS is using spare CPU cycles and disk access to predict whats next and load it into cache. If it is right then you get a 'performance boost' as it doens't have to fetch stuff from disk. But its not really your apps using that memory - its just what the OS thinks is next and it can throw it away whenever. Its simple more efficient than having all zeros there or random bits. You are mixing up swap space and cache (as I did before Ryan P's correction).

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.


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.
NO, your point was that you should have extra RAM even if you are NOT using up all the RAM. As you can see I'm using way over that. Nobody buy nobody is disputing extra RAM is needed in that case. (well.... some people will tell me I should optimisie the code blah blah blah... but those people are idiots who dont' realise its not my code causing the problem ?).

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.
No the swap does what you think cache does. The cache is a speculative exercise than might save you loading from SSD to RAM time IF the OS guessed right. This being said - have more space in which to guess things may improve the odds of guessing right ?

TL;DR: Dollars in RAM often improve performance, more than dollars into more CPU/GPU.

I'm probably more in agreement with you than most on this thread!

Cache is not Physical minus used. In some cases, like yours, the numbers do look like they’re lining up that way, but I’ve seen plenty of cases on my machine when they don’t come close to lining up. I think Cache is a subset of used, but it’s not in the little “App Memory, Wired Memory, Compressed” section because it’s probably a subset of App Memory and possibly Compressed as well. The fact that Memory Pressure lines up with (Used Memory - Cache) / Physical Memory proves that Cache is a subset of Used, not something separate.

I'm not talking from a single time point. Watch it for a while while you load some stuff up - they mostly stay in balance ass I suggested. Cache is physical minus used IF the machine is not too busy doing other stuff (i.e. CPU is at 100% or SSD i/o is maxxed). So it can happen that it won't be used - and it seems to keep a few hundred MB doing nothing most of the time - it doesnt' add up to 100%.

I was going to ignore this but your memory pressure calculation makes no sense.

Edit: Also. Pay attention to the design - the graphic tells you how it makes up physical memory - the littel dent is to show you the thing on the left i.e. physical memory is made up of the stuff in the on the right (App + Wired + Compressed). Its Apple - you know they love such little design features:

image.png
 
Last edited:
  • Like
Reactions: workerbee
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.