Search | Sailfish OS | Running | PineTime | All Posts

How to fix the infamous oom killer in Sailfish OS?

October 01, 2022 — Nico Cartron

Since a few SFOS releases, processes tended to be killed far too often on my X10II. This is now hopefully fixed with that tip!


The Problem

I don't remember precisely in which Sailfish OS version it happened, but it was in the 4.x for sure.

My 10 II was working like a charm before, but since then, apps got killed randomly whenever there were too many (like 3) of them opened.

It happened especially when the stock SFOS browser was open, and also when there are 2 or 3 Android apps running at the same time.

This was super annoying, especially when it killed applications that you were relying on: for instance, it killed a timer I had started to cook pasta, and I realised it too late :(

The Solution

OOM

As usual, the awesome Sailfish OS community came to help!

Matti started a thread on the Sailfish OS Forum where he explained his investigations.

The main culprit he found was OOM Killer (Out of Memory), which as its name suggests, kills applications when there's not enough memory left.
More precisely: it kills applications when the free memory goes beyond defined threshold.

Tweaking OOM Parameters

You can see the memfree values in the file /sys/module/lowmemorykiller/parameters/minfree.

For instance, on my Xperia 10 II, I had: 117160,140200,163240,186280,256490

Those values are device specific, meaning you won't get the same say on a 10 II, compared with a XA2 or a Jolla phone.

I halved eached of those values, so that Sailfish OS does not kill applications too early.

I did so with:

echo -n "58580,70100,81620,93140,128245" > /sys/module/lowmemorykiller/parameters/minfree

followed by a reboot.

Conclusion

I have tested extensively yesterday evening and this morning, with plenty of apps open (stock browser, native SFOS apps, Android apps), with at some point 12 apps open, and no application was killed!

I'll keep testing it but it looks very promising!

Also, I just received my Xperia 10 III (expect an article soon on that!), and I applied the same approach on it (halving memfree values): indeed, even if the 10 III comes with 6GB of RAM (compared with 4GB on the 10 II), it's still worth doing it, to have an even more responsive system!


Tags: SailfishOS, Tips


I don't have any commenting system, but email me (nicolas at ncartron dot org) your comments!
If you like my work, you can buy me a coffee!