4 ms·
I would prefer a process on my desktop be killed rather than my system become unusable to the point of requiring a hard reset of the machine as is common on Lin
by harporoeder 3y ago
I would prefer a process on my desktop be killed rather than my system become unusable to the point of requiring a hard reset of the machine as is common on Linux systems during low memory scenarios.
- arp242 3y agoI've never had an OOM on Linux requiring a hard reset, but you do need some patience for the kernel's OOM killer to kick in – up to a minute or two, perhaps even a bit bit longer (I never timed it exactly).
- account42 3y agoIf your kernel has magic sysrq enabled you can use Alt + SysRq (aka Print Screen key) + F to manually invoke the OOM killer so you don't need to wait.
- bArray 3y agoI've had it trigger regularly, it fires far too late (if at all) and the system had already become unstable at the point in which it freezes. It should be firing far earlier.
- arp242 3y agoYeah, the system locks up, but it should recover – eventually. You just need to go for a coffee, or bagel, or bowel movement, or wank, or whatever. At least, that's been my experience.
- bArray 3y agoNo, it doesn't always. There has been a few times I've left a machine for literal days (when I really needed it to recover) and it does not recover. My guess is that something causes a kernel panic, like the filesystem getting itself into trouble with the hardware.
- wongarsu 3y agoIf you have too much swap configured it can take hours to recover. Maybe days, never let it go that long without giving up. The kernel is terribly slow at swapping stuff back once memory pressure is gone. Of course the remedy is to have no or very little swap configured, but that's not obvious when compared to other operating systems (for example on Windows more swap never hurts, and the system recovers very quickly once memory pressure is gone)
- bArray 3y agoThat and there are some processes that should never be swapped, and yet they are. I think it should be possible for a process to request that it is never swapped, or to suggest sections of it are never swapped. Even a swap blacklist would be a great start.
- mnw21cam 3y agoI have a work server with 384GB of RAM, some swap on spinning rust, and a fairly old installation of Linux, and it has certainly had times when it has taken hours for the kernel OOM killer to sort the thing out. earlyoom was one of the first things I installed on it. I think the more RAM you have, the worse the OOM behaviour. I also think that recent versions of Linux are much better at this than they used to be.
- askl 3y agoTurning off swap should give you this result. Then instead of trying to move stuff to swap which causes the system to be slow or unresponsive, the kernel will just start killing processes.
- dale_glass 3y agoNot guaranteed, there's more than swap that the kernel can use, such as mmap. Disabling swap is a very coarse optimization. The ultimate problem is performance. If you have 16GB RAM + 10GB of stuff sitting completely idle, that works perfectly fine. If you have 16GB RAM + no swap + a process that requires 15GB RAM and uses all of that constantly, it's going to be painful, as the kernel tries to compensate by squeezing memory out of anywhere it can, over and over.
- rcxdude 3y agoNo, sadly. This doesn't happen in my experience. The main reason seems to be that executable code is memory mapped from disk anyway. So in a low-memory scenario, that gets evicted, causing the same kind of thrashing but worse because it's essentially forced to be focused on really active areas instead of the least active. The end result is instead of a slow bogging down like you get with swap enabled, you get a sudden freeze which may eventually resolve itself but during which the system is almost completely unresponsive. In general if you are running without swap I would strongly recommend you do use something like earlyoom.
- mnw21cam 3y agoAgreed - most people don't realise, but even if you don't have any swap, all your executable code is effectively treated exactly the same way as swap (except it's read-only and needed more often). I'd love a setting on Linux to tell it to treat executable pages memory-mapped from disc as Really Important and never evict them. It'd have to come with a suitable warning that if you set this then you get exactly what you deserve, but TBH it probably is what most people actually think is happening already and want.
- askl 3y agoHeh, thanks for explaining this. Maybe my general aversion towards swap wasn't fully based on facts.
- guappa 3y agoUsually it is a process gets killed, its children keep running uselessly, and it's so conservative that most times it was going to work fine. In fact it has been completely fine for me to remove it. The time I wasted having to kill orphaned processes and restarting everything, daily, was easily greater than the hard resets, which happen like once a year or so to me.