Hello folks,
After the enablement of systemd-oomd in Debian [0] we've now integrated the relevant changes into Ubuntu's systemd v249.9-0ubuntu2 package. sd-oomd is a userspace out-of-memory (OOM) killer, that utilizes systemd's unified cgroup hierarchy (cgroup v2, available as of Ubuntu Impish) to track resource usage of individual cgroups and kill them if they exceed their configured quotas [1]. That is before the kernel's OOM killer needs to kick in and while the system still is relatively responsive.
We're shipping a default configuration that uses a MemoryPressureDuration of 20sec and a MemoryPressureLimit of 50% for user sessions. sd-oomd can be enabled on your system by installing the "systemd-oomd" package:
sudo apt install systemd-oomd
For sd-oomd to work properly it needs to have some swap space available and applications will need to spawn processes into separate cgroups (e.g. with systemd-run) or use a desktop environment that does this for them.
I've proposed to enable systemd-oomd by default on Ubuntu Desktop [2], as GNOME is already prepared to launch applications in separate cgroups. I want to invite other Ubuntu flavors to check their corresponding (desktop-) environments for those prerequisites and enable sd-oomd in a similar way, by pulling in the "systemd-oomd" package.
Cheers,
Lukas