Return to

Linux default OOM is bad

There are tools like early oom but the default oom is bad.
In CLI for some reason there’s a 2.5gb cache 400mb ram usage
[free -m]
it seems to kill tasks rather than emptying the cache
[29gb vm will be killed by default oom, even though there’s only 400mb used otherwise] (32gb physical, 1gb swap)
Why isn’t clearing the cache first? How do I tell what it’s catching?

I have no idea if this is the case for you, but files which are memory mapped and locked are counted as cached but cannot be swapped.

That might be done to guarantee program responsiveness while swapping

I read somewhere free ram is not a good thing…

I think this cache is for the system to open up stuff and populate it

but what is happening? is it giving you lock-ups, freezes or slow downs?

what distro? (screenfetch/neofetch would be useful since we’d see kernel and all

EDIT: it’s unused ram is bad, not free

This is Ubuntu in CLI.
When I was using

in virsh, and started using CLI while the VM was active OOM would kill the VM as it was out of memory - but checking
free -m when it killed the VM there was 400mb used, 2.5gb cached. So seems cacheing exceeded the available memory so oom killed the VM. I don’t know why it’s cacheing so much when I’m just in CLI.
Using ps -aux sudo ps -a everything seemed normal - bunch of BTRFS stuff, root login, apt… and cached doesn’t seem to be represented by %mem only used seems to be represented by %mem…

1 Like

Memory management is far more complicated on modern systems. For instance if you have more than 1 NUMA node you could have one run out of memory when there is plenty of total memory free and because of memory pressure or processes being locked to the NUMA node OOM killer gets invoked.

If there is too much memory pressure and the cache cannot get cleared fast enough OOM killer gets invoked.

There are other things that can reserve memory that will show up as cached which could prevent that from being freed up. There are tuning parameters that can limit the cache usage and allow memory to be freed up faster (I don’t know off the top of my head exactly what all these settings are).

If you don’t have swap configured there could be some benefit there as some software will request swap when it needs temporary storage, but does not need it to be fast and if there is no swap RAM is used. You don’t generally want to be actively swapping data into and out of swap, but there are still benefits from having it outside of that.

Also of note you mention BTRFS, as that is still not considered stable by the devs you could have run into a bug somewhere there, worth looking into in my opinion.