If you’ve found memory management in Ubuntu a little on the aggressive side since upgrading to 22.04 LTS know this: you are not alone.
A discussion on the Ubuntu mailing list highlights issues scores of users are experiencing. Out of the blue, with no indication anything is wrong, apps like Firefox, Chrome, and Visual Studio Code just die… Blink out of existence.
At fault? Ubuntu 22.04 LTS’s introduction of systemd-oomd, a user-space out of memory killer that’s designed to “take corrective action before an OOM occurs in the kernel space’. When it detects that memory pressure is getting a bit too stressed, it intervenes to ensure the system copes, and (most) things stay running.
But it seems that it’s being triggered too frequently, killing apps even though memory isn’t at a critical impasse.
“There should be a warning prior killing apps to give the opportunity to save the app data. There should at least be an apologize and an explanation after killing the app. The current behavior gives the impression that Ubuntu 22.04 is unreliable and unsafe to use which is a problem for an LTS release”, writes one frustrated user (all sic).
“I was watching some video in Firefox. I popped over to another virtual workspace for a few minutes, and when I popped back to Firefox it had gone. The same thing had been happening all week (I installed fresh Ubuntu-22.04 last week) with Chrome, Firefox and Thunderbird”, recounts another.
S’going on, ‘Buntz?
Canonical’s Nick Rosbrook explains the issue(s) at play in more detail in his mailing list post. “The common theme in these reports”, he writes, “is that e.g, Chrome is killed ‘suddenly’ without any other observable symptoms of the system nearing OOM”.
A number of possible solutions are put forward to mitigate the aggressiveness. These range from altering how memory values are calculated/triggered by systemd-oomd, to disabling the feature entirely and letting the kernel handle OOM situations instead.
Another mooted solution is to increase Ubuntu’s default swap file size. On most installs this is just 1GB. Doing this would alleviate the issue of the swap limit being hit too easily, triggering the unannounced app exits, but isn’t something that can be applied to existing systems automatically.
Or at least, that’s my understanding. I’ve been a touch reductive in my summary as low-level technical workings such as this are not my area of expertise —before you ask, I don’t have any area of expertise, not unless sleeping in too late counts 😅.
But as someone who is affected by this issue — I thought it was just my system prior to today — I’m keen to see how things play out. There’s no firm conclusion on how to proceed for now. I’ll be keeping an eye on the situation as we inch closer to the first Ubuntu 22.04 LTS point release (due next month).
If you’re keen to learn more do check out the mailing list post yourself. It’s an insightful glimpse into a system features that most of us never stop to think about.