Thursday, January 26, 2023

What Happened to Virtual Memory?

alessandro308:

Your system has run out of application memory.

To avoid problems with your computer, quit any applications you are not using.

Jason Koebler:

why do people pretend like RAM is somehow not important on Apple Silicon? I have a $2,000 14" 2021 MBP with 16 gb RAM and I’m regularly getting notices my computer can’t run bc not enough system memory with not that much stuff open[…]

meanwhile I have a 2017 iMac that I installed 32 gb of RAM on myself with a garbage processor but that generally runs large numbers of programs/tabs better than this MBP.

I’ve never quite known what this error means. I’ve been using macOS since the beginning and don’t recall ever seeing it until the later years of using my 2017 iMac. It had 40 GB of RAM, and when I would get this error it never seemed like applications were using a huge amount of memory. Sometimes it looked like the kernel was using 10 GB or so. Even so, how can the system be out of memory when it supports virtual memory and the boot drive has 100 GB of free space?

Meanwhile, my 2022 MacBook Pro has only 32 GB of RAM, and I don’t think it has ever shown this error message. My guess is that this is because the MacBook Pro has a larger SSD and the iMac was in fact running out of space. Perhaps it’s just more confusion caused by displaying purgeable space—that will not actually be automatically purged—as though it’s free.

Previously:

Update (2023-02-14): Alexandre Colucci:

Achievement unlocked: memory swapping on Apple Silicon 🤘

Update (2023-04-24): See also: Mike Richardson.

Update (2024-03-01): Christian Selig:

Anyone else getting a bunch of “your system ran out of memory” alerts on Sonoma, but then you add them up and they’re nowhere near your total RAM?

Update (2024-03-05): Saagar Jha:

I believe you see that alert when your system cannot swap anymore because there isn’t any disk space left. I don’t believe swapping will ask the system to purge anything btw[…]

Gok:

There is also a lot of memory that can’t be swapped. e.g. Chrome and therefore Electron are putting more and more things in IOSurface allocations that can’t be paged out.

4 Comments RSS · Twitter · Mastodon

I've had this twice:

- the original MacBook Air M1 (work computer), didn't seem to use swap!, was at hardware diagnostic steps and going crazy, when the next OS update came out it just went poof! and the issue disappeared

- more recently would happen inconsistently on waking from sleep (new MacBook Air M2, home computer) - turned out to be due to using the photos screen saver, which seemed to consume enormous amounts of memory (local hi def photos?) https://discussions.apple.com/thread/254314900

I've been getting that message on a 64GB Macbook Pro. Activity Monitor doesn't give a clue as to the resource hog. It tends to start when my system has been up for a month or two, so it might be some cruft metric.

It’s hard to not see a relation between this post and the one from a few days back about code quality (though memory management being low level, this shouldn’t be the case)
Issue is that with increased abstraction between user and system, it’s hard to discern what is really going on. (ie. Finder may say you have free space to swap on, but below the good things may look differently because the system hasn’t purged its caches)

I get that from the Slack tab on Safari on the work machine. Killing the process nightly helped. There's something about Webkit and Slack that seems to cause Webkit to not dump Slack's crap into virtual memory (or throw it away). This occurred after I wrote an applescript thing to reload slack every 5 minutes because it kept losing its connection over my Internet connection, and I'd miss important messages. My guess is that slack loads web-service workers that never go away, and are called on a timer, so that by the end of the day I'd have accumulated a ton of them, and they have accumulated a ton of my RAM.

On 10.8, the most similar error was "Your disk drive is full".

That might have been confusing, but but was correct: if you looked in /var/vm you'd find it full of Gb sized swap files. If you ran "df ~", you'd find the drive was full. I only ever had it because Chrome made a process for every Tab it loaded. And for some reason it NEEDED to create a process for every tab, even if no one ever looked at it. Once you killed Chrome, the swap daemon would consolidate these files, returning the space on your HD. I ended up moving from Chrome to Pale Moon (firefox). It behaves, if you turn the internet connection off while it starts up... yes I'm bad it inbox-0 and tab-0.

Leave a Comment