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

jadraker

macrumors member
Original poster
Oct 24, 2018
38
25
Santiago, Chile
Hello guys,
I'm using Monterey in my MBP 2018 (i9, 32 GB RAM) and it's working pretty well. In my daily work I've a Windows 11 VM running in VMware Fusion along with apps loaded in Monterey like OneDrive, Outlook, Word, Excel, Chrome and Safari.

The system works pretty well but I don't understand why Mac is sending to swap about 5 GB when RAM is available.

1636657361124.png


Is this normal or am I being affected by the infamous memory leak of Monterey?
 
More seriously I think they have some issue deep somewhere, more related to reporting/detection than actual memory usage (and then provoke the swap usage).
 
It’s been like that for a thousand years. It was way worse in snow leopard where it’d thrash the disk and make the OS super slow even when RAM was available. They seemed to have dialed back this behaviour starting with mavericks but still happens.


supposedly, when you starting eating a ton of ram, it pages out infrequent/inactive stuff onto the disk even with ram available (if compression isn’t enough)so when you for example, load up another VM, it can quickly be loaded in because now you have enough physical ram
 
  • Like
Reactions: hwojtek
Your workflow probably needed 29GB+ of RAM at some point — I think, macOS starts paging out when RAM usage reaches within 10% or less of free memory.

I’ve read that when more RAM space becomes available, the swap file(s) will not be deleted/removed until system shut down even if/after paged content is reloaded into memory.
 
You could try TURNING OFF VM disk swapping.

This assumes you are able to "manage" the 32gb of installed RAM that you have, by keeping an eye on open applications, etc.

I've been doing this for YEARS now, with no crashes nor problems.

A report from terminal (taken moments ago):
vm.swapusage: total = 0.00M used = 0.00M free = 0.00M (encrypted)

Screenshot from activity monitor (taken moments ago):
swap used.jpg
 
Poor memory management. Mac OS doesn't release cached files from memory, and actually prefers swapping to disk.

It has been like that for many years, but actually it works a bit better in Monterrey. Cache is not filling up with garbage as it used to be.

brew install stress
sudo purge
 
  • Like
Reactions: gilby101
I can't give you a specific answer which depends on the situation you are/were in.

Broadly speaking, the OS isn't only concerned with how much free memory is there available 'now' but also on how fast it can provide memory to any process that requests it. Even if you see the stats as fixed numbers, applications are constantly allocating and freeing up memory. When an application requests some memory if there's not enough available to pass around the OS will do some work to make it available if possible: this introduces a pause in the application, which will be stuck. To lessen this pain the OS will always try to have free ram available to pass around.
How much should it keep free? You have no way of knowing beforehand what will be required, so you might set aside a fixed amount, let say 10% of total memory. Or you can try to be clever and start measuring things, like how fast new memory is being allocated vs freed, how often some specific memory regions have been accessed. Does that program that has loaded an image in memory two days ago and never ever accessed it since really benefit from keeping it in ram or would the system be faster if that area is swapped out and the memory put to different usage? ... and so on.
The OS has various systems that will try to gauge how to manage memory to optimise the total system throughput and they might decide in some situations to swap out some memory even if you have plenty of free ram.

Just to give you a clue on where the answer might lie...
 
You undoubtedly have the Monterey memory leak bug:
You, like me and almost everyone who uses Monterey,. has the dreaded memory leak bug. Apple will fix it eventually.

Before then there is a simple temporary solution. Presumably you have several desktops on your mac. I have 11 at the moment. Go to one you don’t use often and open up Activity Monitor(its in your applications and on every mac). Leave it open all the time. Click on the column that tells you the use of memory by system processes and apps. Highlight(click on) any that look completely out of control, and then click on the little icon with the x in the middle of a circle. Choose force quit. If its an app it will quit and you will have to restart it. If its a process(weird names mostly) then it will quit but come back almost instantly in the small size it's supposed to be. For me about 15 minutes ago I noticed that the most common culprit, Control Center(which normally uses about 26 mb of memory) was slowly sucking more and was up to 144mb. Earlier this week I found it at 14 GB.

You can keep these little buggers from stealing memory by just keeping an eye on them. Be advised: if WindowServer is up at 1gb then its probably doing it too, and if you force quit that one, your screen will go black for about 5 seconds while the OS puts it back, and then you will have to type in your machine password again.

Hope this helps.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.