Linux Mint 21 Is Going To Avoid systemd-oomd
phoronix.com
phoronix.com
A few of the settings will vary based on the amount of RAM one is willing to commit to the kernel and prevent user applications from using.
Examples only, please do not use these in /etc/sysctl.conf without first reading and understanding the documentation. [1]
vm.overcommit_ratio = 0
vm.overcommit_memory = 0
vm.swappiness = 150
vm.admin_reserve_kbytes = 256000
vm.user_reserve_kbytes = 131072
vm.min_free_kbytes = 768000
The last 3 numbers should be adjusted based on the memory in ones workstation or laptop. Redhat and Debian have formulas one can use to find the optimal number but I do not have the links handy. I set them really high to prevent user applications from spawning if memory is low. For example, on a server with 512GB of ram I set the min_free to 4GB.Swappiness range is 0 to 200. Higher will start swapping earlier but in reality this should rarely occur if the system was configured with the correct amount of RAM for the machines intended usage. The rationale behind setting this high is to reduce the risk of a race condition where inode or dentry cache is not evicted fast enough.
Overcommit_memory 0 does not actually disable overcommit. That setting is 2 to disable entirely. The setting of 0 implements a simple formula ram+swap*{ratio}. Setting to 1 will always permit over-allocation.
One can also use cgroups and/or containers to put boundaries around application memory use.
More details are available on kernel.org [1]
[1] - https://www.kernel.org/doc/Documentation/sysctl/vm.txt