Comment by phiresky
17 hours ago
Which OS are you using? systemd-oomd (or similar) afaik is enabled in many modern releases and fixes it. The default settings (on Arch) make it kill stuff when your CPU is spending 60% of time on reclaiming memory over some time period. So you'll get 20 seconds of lag, then it is fixed.
By killing a program, yes, but how else do you expect it to work? If your RAM is not enough you have to kill stuff. And I really doubt you mean to say that Windows is _more RAM efficient_ than Linux, because that's kind of absurd. Maybe Firefox is less RAM efficient than Chrome.
Edit: MacOS I wouldn't doubt being better in RAM management than the others because they have been selling their devices with ridiculously low amounts of RAM for decades.
> how else do you expect it to work
How does it work on Windows and MacOS where I don't get the same freezes and random programs aren't killed by the OS? Because I'd expect it to work like that.
There is this false dichotomy, a black and white kind of thinking on display.
> And I really doubt you mean to say that Windows is _more RAM efficient_ than Linux
What I'm saying ought to be clear to anyone willing to listen. My system should not get into an unrecoverable freezing state when I am doing routine tasks on a fresh install of an OS. And the community that is supposed to champion this OS should not then shift the blame to me if I complain about it.
"How does it work on Windows[..]"
This video from Mark Russinovich is a classic explaining it. It is old but still relevant.
https://m.youtube.com/watch?v=AjTl53I_qzY&ra=m
"My system should not get into an unrecoverable freezing state[..]"
There is a good precedent for what you want: Safety critical embedded systems. Your car ECU should not be in an unrecoverable freezing state when you want to break.
These embedded systems also are known to be terribly memory inefficient because every bit of memory is statically assigned and never reused.
So, it is not that what you want is impossible, it's just wasteful and expensive.
Linux and Windows sit on slightly different points on this spectrum (opposite of said embedded systems) and what you perceive as Windows' better behavior under memory pressure has a price too.
and killing programs and/or freezing the OS is somehow more efficient? By what metric? Certainly not by any UX or productivity one.
I've moved to Linux from Windows some years ago but the first thing that shocked me was precisely the abysmal performance around low memory availability.
Got my system stabilized eventually by means of some magical incantations but this wasn't a pleasant experience and I wouldn't want to repeat it.
It's beyond me how come Linux is so decrepid in this particular area compared to Windows.
I get memory related freezes on macOS all the time.
And back when I was forced into running Windows, I used to get memory-related freezes daily. Literally daily.
So I’m really not convinced the situation is drastically different there. I mean if it were that simple, Linux would have fixed it already.
Yeah I got MacOS freezes sometimes - never checked Activity Monitor to see why though.
On Windows it's usually the hard drive being over-used that makes things drag for me.
1 reply →
Windows makes you miserable when low on RAM. Linux makes you miserable when you get out of RAM.
macOS shows a modal with a list of offending applications and how much RAM they're using. Some of those applications are "paused", marked in red, some are "not responding", and some are responding normally.
You can pick applications from that list and choose between "Resume" (for "paused" applications) or "Force Quit".
At no point the system becomes unresponsive.
Freeze as many applications as necessary to reserve room for the DE so I can choose what to do?
Surely that's obvious to other people aside from me. It's an attended system, not a headless server in a rack hundreds of miles away that must not ever alert someone.
The ideal would be to go into swap without becoming unresponsive, so that the user can quit a program of their choice to free memory. If you really want to make an issue out of it, do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory, so that a user might have the chance to do something before the current process starts getting swapped out.
> The ideal would be to go into swap without becoming unresponsive, so that the user can quit a program of their choice to free memory.
Linux already does this. The issue is when your swap is full too, or you’ve exhausted your RAM at such a rapid pace that the disk IO cannot keep up with the read and writes to swap.
I’ve seen Windows choke under the same conditions too.
> do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory, so that a user might have the chance to do something before the current process starts getting swapped out.
This is where the desktop and the kernel being entirely separate organisations (not even projects, but literal organisations) makes things a touch harder. And those DEs aren’t even Linux specific either. So any tooling would have to portable (which, in fairness, should be possible with POSIX in this particular scenario).
I think KDE does provide tools here for gracefully handling memory constraints. But that’s just one desktop environment of many.
>> do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory
And I've run out of memory while compiling packages (I'm looking at you, composable-kernel) on Gentoo. It's not like it can notify me and I close things in the milliseconds it takes for a few more GCC processes to spawn and allocate and fault all the remaining memory.
Swap is extremely slow. And if running it on a high-end NVMe, you better hope you don't swap often.
Firefox is definitely more RAM efficient than Chrome, in my experience.
Linux can, and does, prevent a program to claim any new memory. Like literally malloc() returns null. How program reacts to that is up to the program.
Also I know linux has `cgroup_enable=memory` setting in /etc/default/grub, that's for Docker/K8S to be able to watch over containers RAM. It's not enabled by default as it slows down OS a little. Don't know if it's related to my first point.
Call me an old geezer but I remember having this thing called swap.
Yeah, I'm super confused. Is the 34 year old solution to this (swap) somehow broken these days?
Right, and when it gets filled, the OOM killer comes along and does its thing.
On some platforms. Others make other arrangements, with other tradeoffs.
It's been less than 24 hours since an OOM killer was identified as responsible for a bug I was experiencing.