Hacker News new | past | comments | ask | show | jobs | submit login

Linux still can't handle out of memory issues gracefully.

Sometimes I create memory leaks or use too many electron apps and when you hit a low memory situation Linux starts trashing and your system becomes unusable for minutes to hours unless you reboot your machine.

Mac and windows both manage to handle this gracefully by force suspending background processes it seems.

This makes Linux on the laptop hit or miss, multitask too much and your system effectively locks up. Laptops tend to have less ram available.




> Linux starts trashing

You mean intensive use of swap memory? You could turn off swap and get OOM errors instead if you like a snappy system, but I don't know if it's fair to criticize an OS for running out of memory. It's the user fault for using software that demands more resources than the equipment has, or for not expanding the RAM when it's clearly needed.


I've experienced this too. Swapping seems very slow and inefficient on Linux. No matter how large your swap is, once you hit the point where you're using twice your physical RAM, the system become unresponsive. My guess is Linux doesn't prioritize processes properly for desktop use, and background threads, despite being from minimized windows (minimized by the user in a desperate and futile attempt to open a terminal so I can kill some processes), are free to demand memory with the same priority as everything else.


On the other hand I absolutely can blame an OS for not letting me set a minimum amount of memory for the disk cache.

Even if I disable swap, when Linux gets very low on memory you get the exact same symptoms when it starts discarding increasingly-active program code.


I have swap turned off and I don't get OOM errors. System just crawls and is unresponsive. Usually happens because of Chromium. If I manage to kill it, then it comes back to normal.


I've turned off swap, it still happens.

It's not the users fault. Every other major OS handles this situation.


I was able to crash MacOS 12.5.1 a few weeks ago, by allocating 80+GB more than I had swap/memory space for. Over use/abuse of memory system leading to unstable system is not specific to Linux.

In my case, I was doing development/testing of a data analysis code. Pulling in the data was fine, I just needed to adjust my applications queries to reduce the size of this. I was specifically looking to see what I could get away with in terms of analysis size without adding additional code to handle out-of-core.

MacOS did not respond gracefully to the load. It took it a whole 20 minutes to crash, hard-locking the UI, and eventually rebooting.

My previous experience with a windows laptop (until I traded it in for the mac about 10 months ago), was even worse. I could not use WSL2 for anything approaching real memory utilization, as I'd get all these memory compaction pauses/GCs. These random freezes would often hang the machine for a while, and when it resumed, the interface was very laggy.

Compared to that, my linux experience for systems under horrific load is much better than windows, and on par with MacOS (M1 32GB laptop BTW, not a small system).


Depends on your configuration/distro. OOM killers aren't really used on the desktop because swap makes more sense, but you can certainly add one if you're using a resource-constrained machine.


OOM killer is a pseudosolution to an artificially created problem.

https://lwn.net/Articles/104185/


Then don't use it. Most distributors don't enable it by default for a reason.


> Most distributors don't enable it by default for a reason.

Every Linux system configured for overcommit (every major distribution out of the box) will invoke the kernel OOM killer upon demand. There is no such thing as distributions not "enabling" this thing. You're talking about things like systemd-oomd, which act as a layer on top of the kernel OOM killer.


Yes, but that still leaves the problem, which shouldn’t exist in the first place (edit: and on Windows doesn’t).


This could be fixed with a little UI work in gnome. Eg. when running a RAM heavy program, if more than 80% of memory gets used, then whatever program is using most gets halted, it's window greyed out, and a popup saying "Your system memory is 80% full, and Google Chrome is using 65%. Would you like to kill Chrome or close some other applications to allow it to use more?"


You're probably using an old version of systemd without oomd. If you can wait a little, MGLRU will soon fix that in the kernel; no other software will need to be installed or updated.


Neat thanks for the pointer! I'll definitely follow MGLRU with interest.


It sounds like you're running without a swap file. You should really enable that.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: