Tuning the oom killer / low memory killer

I tested the halving briefly, and had similar results, unfortunately.

It looks like the limits are quite well tuned for X10II. If that is indeed the case, I see no reason to double the values for X10III only because it has double the RAM.

We are slowly narrowing the acceptable window here, which is good :slight_smile:

5 Likes

Itā€™s been two weeks since Iā€™ve been using halved values on the 10 III, without any problems and with not a single occurrence of closing any app due to OOM, with the single exception of the web browser, which happened once. So Iā€™m more than satisfied.

2 Likes

My experience showed better results when halving the freemem values on my X10II. With the default settings, the Android App Support system gets killed most of the time after I watch a video in Fennec (Androids Firefox Browser), as soon as I stop using my device. Next time I turn on my screen, all Android apps are greyed out and opening one of them starts the Android App support first.
Since I started adjusting the freemem values, this rarely happened.
As Iā€™m only using a few apps on my phone, this may not be the average user use case.

2 Likes

joining the boat here :slight_smile: just tweaked minfree on my 10 II with 58580,70100,81620,93140,128245, I have 4 Android apps open + stock browser + Fernschreiber, and the system is still smooth, and no crash so far :crossed_fingers:

7 Likes

I have posted a bug report for them to consider lowering those values

3 Likes

So I just changed my default values after I really got sick with apps closing down randomly. Following @cartronā€™s tweak I changed from

[root@Xperia10II-DualSIM defaultuser]# cat /sys/modul
e/lowmemorykiller/parameters/minfree
117160,140200,163240,186280,256490

to

[defaultuser@Xperia10II-DualSIM ~]$ cat /sys/mod
ule/lowmemorykiller/parameters/minfree
58580,70100,81620,93140,128245

I will report back in the next couple of days whether I experience an improvement or not.

What I learned so far:

  • I have to set the limits after every reboot
  • Fennec can be killed like before
5 Likes

I have also modified the config on my 10 II.

Here is my experience:

  • Apps no longer close on their own.
  • Got 3 cashs in 2 days (0 in the last 6 months)

I am back to the default configuration.

2 Likes

I was hit by random OOM kills, too that made using the device (10 Mark 2) nearly impossible.
There where a few things I recognized:

  • SailfishOS browser pinch-to-zoom eats memory, e.g. open some github project source code file and zoom in. Now scroll a little bit inside that zoomed file and bang there you go (LMKD is killing a bunch of running applications in a blink)

  • I had a memory leak caused by faulty / broken Sailfish MTA that consumed a lot of memory but alas itā€™s a system process so other running non-system applications got killed first

My solution to the latter issue was to re-create my mail account which resolved the MTA system process memory leak that caused LMKD to hunt down my other non-system applications.

Now thatā€™s what I call ā€œinterestingā€ā€¦ How did you figure it out that it was the MTA process that had the memory leak? Asking for a friend :wink:

1 Like

To be honest I had a bad feeling when syncing my mailbox (IMAP4) suddenly took very long and ended eventually with sync failures. After that I recognized that running multiple applications (Android: ntfy.sh, Schildichat; SFOS: Mail (backround), browser, Quickdit, forum viewer, Podqast) where killed overnight.

I didnā€™t dig any deeper nor analysed logs (which would be more objective). However after I fixed my broken mail account no overnight or common use crashes of running the same set of applications occured to me (knocking on wood).

What I wanted to say is that system processes are allowed higher memory demand before they are terminated so in the end faulty system processes can trigger the LMKD killing of unprivileged processes and you wonder why the heck are my applications crashing all the time.

I updated to 4.4.0.72 and my changes to the /vendor/etc files was reverted. Just realized when I got pulseaudio killed today (or yesterday).

1 Like

yes, this doesnā€™t survive a reboot.
Iā€™m looking at options, it looks like using udevadm could be an option, iā€™ll try to find some time over the week-end to look at that, and will report back.

typo in your formula

it is *4 / 1024

You can edit this file, it will work till the next OS update. The numbers that direc posted last were the best I think, or values used by 10 II, both quite similar.

omg was to stupid to click on insert in vi

LOL

thanks

1 Like

Thereā€™s place for improvement on the XA2 devices tooā€¦ Iā€™ve had more frequent crashes lately, seemingly related to RAM usage. Typically, my browser would be killed when starting a big Android app. Or the Android app would fail to start if there were too many apps open.

Hereā€™s what helped on my XA2:

printf 768,1024,2048,4096 >/
sys/module/lowmemorykiller/parameters/minfree

Iā€™ve been using these settings for some weeks. Two other XA2 users have also tried them successfully. There still are OOM kills, but markedly fewer.

6 Likes

To recap, on Sony 10 Xperia III, we are changing the default value of ā€œminfreeā€ (which killer was that?) by:

[root@Xperia10III defaultuser]# nano /vendor/etc/init/init.lena.rc
167160,190200,213240,236280,356490

to be changed to:

65536,73728,90112,131072,196608

Save and Reboot.

A Reboot will reset the values to default. How to overcome that?

Do we change the values from here instead?

[root@Xperia10III defaultuser]# nano /vendor/etc/init/init.lena.rc
    # LMK tunning
    write /sys/module/lowmemorykiller/parameters/enable_lmk 1
    write /sys/module/lowmemorykiller/parameters/minfree "167160,190200,213240,236280,356490"
    write /sys/module/lowmemorykiller/parameters/adj "0,58,147,529,1000"
    write /sys/module/lowmemorykiller/parameters/vmpressure_file_min 105984
    write /sys/module/lowmemorykiller/parameters/oom_reaper 1

Yes indeed, survives a reboot.

Is this the only step or change that we need to perform, changing the values within ā€˜/vendor/etc/init/init.lena.rcā€™; or there is another step need to be taken?

Like

[root@Xperia10III defaultuser]# nano /proc/sys/vm/swappiness

And chang the value from 25 to 50?

50

Yet that resets back to value 25, after a reboot.

And regarding

Are these values, ā€˜15360,19200,23040,26880,34415,43737ā€™ imply to Sony 10 Xperia III, or Sony 10 Xperia II ?

My Sony 10 Xperia III is in constant freeze and crash when I do have any Android app up, specifically OSMAnd android map app, or any mapping package, like Pure Maps.

This and for some reason only happens when I am outdoors, walking within the city.
Perhaps this RAM process of killing apps what is causing this, and with the GPS issues, networking [since I reside in the US, not all bands my phone can pickup]?

Thank you all for this wealth of informationā€¦ One of the best forums to follow

2 Likes

Those are Xperia 10 II values that I suggested using on 10 III. Those are not that much lower than what 10 III is using, so should be pretty safe.
What direc suggested should bring bigger improvements though, 65536,73728,90112,131072,196608 as you even said in your post.

Thank you for the update, oh, I stole all the info and and compiled a summary; I am thankful to all of you for the this great troubleshooting.

Regarding ā€œpage fileā€, after a reboot the value on the phone will set back to default, on Sony 10 Xperia III, when I use this command, after SSH into the phone:

nano /proc/sys/vm/swappiness

I do get the value (which I assume in percentage 25% of total RAM of 6GB)

25

Of course, I do change the ā€˜percentageā€™ value to

50

And a reboot will set the value back to ā€˜25ā€™:

cat /proc/sys/vm/swappiness
25

I have tried different methods, thinking the page file is somehow controlled by ZRAM settings, like at:

cat /vendor/etc/fstab.pdx213

and at this line:

#ZRAM/SWAP
/dev/block/zram0                           none                    swap    defaults                                                              zramsize=1073741824,max_comp_streams=8

the value of 1073741824 = 1024MB

And when I replaced these numbers ā€˜1073741824ā€™ with 3GB, and did reboot, I do not find the value changed within ā€˜/proc/sys/vm/swappinessā€™, rather, disapperance of ZRAM swap value, and even reverting back, I do get the same result below [I sespuct the way how I did edit the file]

cat sys/block/zram0/disksize

will yield at the moment,

[root@Xperia10III defaultuser]# cat sys/block/zram0/disksize
cat: can't open 'sys/block/zram0/disksize': No such file or directory

Yet, would it be from there, sys/block/zram0/disksize, the value of ZRAM swap page-file size will be defined, and persistent even after a reboot?

Do I need to recreate the ZRAM via dd command?"

Thank you

Setting the values in /vendor/etc/init/init.lena.rc indeed survive reboot; thatā€™s what I currently use as well.

Swappiness value is set at boot time, it seems to be set in /vendor/hw/init.pdx213.rc but I havenā€™t tested that. Try it on your own risk! But; I donā€™t think swappiness has that much effect on all this, I suggest leaving that alone. OTOH it doesnā€™t hurt either, so thereā€™s that.

I havenā€™t tried increasing zram size, but I think 3GB is way too much. If the kernel canā€™t allocate that much, you wonā€™t have zram at all. And if it succeeded, and almost all of it was in use, youā€™d have serious trashing going on and the system would have grinded to a halt long before that.

You donā€™t have to create zram via dd, the kernel handles it all.

2 Likes