Low memory, apps crashing - change zram settings or add swapfile? [4.x]

I can confirm that komoot is crashing after some minutes of usage. No other apps open or in background at this time. This is valid for all other navigation apps I am using - OSM and Here. I am on a XA2 and discovered this behavior with the latest version of Sailfish. Can not remember seeing this before.

Yes, it gets mounted at boot :

[defaultuser@Xperia10II-DualSIM ~]$ cat /proc/swaps
Filename Type Size Used Priority
/dev/zram0 partition 524284 311104 -2
/swapfile file 1048572 0 -3

/swapfile is owned by root and rw-------.

Ah OK. I checked if the swapfile in the root directory gets automounted and it works.
Here are the two lines in the fstab:
/home/swapfile none swap defaults 0 0 doesn’t work
/swapfile none swap defaults 0 0 works

Great, thanks for the feedback.

After some testing with an additional swapfile I can say that the problem still exist. Navigation Apps still crashing after some minutes. I can see that swap is growing after start but with a maximum of 150MB. Memory used is growing from 1,3GB in idle without any apps to ~1,8GB then crashing. How much memory do your devices consume after start without any other apps?

That is really not a good metric with Linux kernels which follow the “free RAM is wasted RAM” philosophy. On a properly working system you could see 99% used memory all the time and nothing crashing.

The whole thing is made even more complicated on SFOS where the native side and the Android side use different technologies for dealing with low memory situations - and the technologies used differ from device to device and release to release.

See also:

2 Likes

Thanks for the hints. By used memory I meant the active memory. There was a bunch of cached and buffered memory too so that free memory was something round 40MB before crash. After studying the links in your post I understand the problem better.

Tested this on XZ2c, and definitely improves things… Infortunately, my remaining system memory is barely over 1g as is. Maybe will test 750 or something…

Unfortunately it got worse with 4.4.0.58.
Browser update (bigger memory consumption) causes problems with other apps. :frowning:

I recently acquired a SanDisk Extreme Pro 64GB memory card. Specs says it puts out 170 MB/s read and 90 MB/s write. On my Xperia 10 II I disabled system swap and enabled swapfile on sd only. I also messed with swappiness to test things out. 6 android apps and 4 system. Device is noticeably slower when switching apps but overall very stable. Once app is switched it acts normal. I need to test things some more but it seems that sd can be a replacment for internal swap. Anyway, I would like to test performance with both swaps equal size (internal and sd) mounted with equal priorities. In theory this should ads up speed of sd and internal, or am I wrong?

I’m not sure it’s a good idea to add SWAP on your SD Card…
Usually, the less you write on a SD Card the more its longevity increases.

But this is exactly the point of it. sd card is replaceable internal memory is not.

But if not, anybody have an idea how to grant equal prios to each swap, internal and sd?
No matter what I do they end up beeing different :confused:

Hi again

Can someone explain how to run two swap places with equal priorites? No matter what value I set both swaps ends up with different prios,

Also, did someone figured out how to apply custom swap places and swappiness settings at startup?

For swappiness, I’d try standard sysctl approach; for some reason there’s no sysctl.conf on Sailfish, but you can create file – let’s name it local-swappiness.conf in /etc/sysctl.d and put

vm.swappiness = 90

(whatever value you see fitting) in there. Name is irrelevant, I used local- prefix to avoid potential conflicts, just remember the .conf extension is needed.

Can you show, how do you try to set swap priority?

Will this also work with swap settings as decribed below?:
swapoff /dev/zram0
swapon -p 2 /run/media/defaultuser/6239-3830/swap
swapon -p 2 /dev/zram0

This gives me two equal swap spaces with equal priorities and this indeed works nice, 6 android and 6 system apps were around full ram and 75% of swap and everything worked stable. I previously tried giving minus somethings priority value but it didn’t work for unknown reason, giving it prios above 1 works.
It just would be nice to have this on startup rather than typing this into terminal each time I reboot :confused:

1 Like

If nobody wants to fix me with right solution for changing swap settings automaticly maybe there is one person which can point me into right direction? Is there a place where I can put executable script?
What is the full path of swapon & swapoff?

1 Like

Bumping it up, please somebody help

1 Like

What i am curious about is the behavior on the 10 III.
I thought the 6GB? of Ram would fixx the behaviour - but after some days uptime some apps still get killed…

3 Likes

Just want to confirm this really works brilliant for me as well (xperia 10ii) and I have to recommend this modification for all users.
And yes it’s fine to reboot. However, this modification has to be redone after system upgrade but that’s only a minor issue.
Maybe it’s possible to pin this guide somewhere, otherwise it’ll probably get lost in the archives again.

2 Likes

Another X10II confirmation here: adding 1G swapfile is already making all the difference. I’m ready to double it, too. Flash wear issues or not, it does seem like anything is better than superslow oomkillers needing to get involved.

Relying on swap heavier does seem to make sense here, because in most cases background apps just sit there near-idle, waiting to be beckoned. That’s perfect for swap and its related performance challenges.

EDIT lol right after posting this, lipstick took all my apps away. Testing 2G swapfile now.