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

Well, that is all computers these days. Also, modern PC/Laptop SSD is different from internal phone storage, quite resistant to wear by many small writes.

I wonder if putting a swap partition on SD card would be better. Yes, performance will suck, and yes it may kill the card at one point. But it’s easy and cheap to replace, contrary to internal phone storage.

Not as terrible as was originally thought. Obviously the tech has improved since early flash memory cells, with wear-levelling techniques etc.

https://www.guru3d.com/news-story/endurance-test-of-samsung-850-pro-comes-to-an-end-after-9100tb-of-writes.html

However, my experience so far (only a couple of days) is that the swapfile is only being used occasionally and the max usage I’ve seen is ~200Mb - but I have a learned habit now of closing apps to prevent issues, only leaving open super-frequently used apps. Maybe I wont do that anymore…

I’ll see how it goes, then I’ll experiment with increasing the zram instead and see if I can find a better balance with that. Apparently the theory is it’s faster - sure accessing the swap is faster because it’s in RAM but surely the CPU is working overtime compressing and uncompressing constantly?

Amazing thanks.

On Xperia 10ii it’s here:
/vendor/etc/fstab.pdx201

First line of the file though is:

# Android fstab file.

Is that misleading?

I’m assuming I can add my swapfile here as well.

Originally I tried adding to /etc/fstab but that was when I had the issue. Hesitant to try again because even testing re-mounting everything seemed ok before a reboot. Trying to get into and back out from Recovery mode was a nightmare!

Totally not tested, but can’t systemd set up the swap file?

/usr/lib/systemd/system/swapfile.swap

[Unit]
Description=Swap File
Before=swap.target

[Swap]
What=/swapfile

[Install]
WantedBy=swap.target
1 Like

Yeap, I can confirm, this is highly similar to what I’m seeing on X10II.

Only ever had microG.

And I try not to go over 20 browser tabs, any more than that and it starts to struggle (as do I with remembering what I needed each tab for :wink:

I believe it can, but not tried yet. I’m only a fairly basic linux tinkerer!

This unfortunately can only be fixed either by optimizing the system (which clearly goes in the opposite direction so that’s not an option) or by increasing the amount of available memory. I’m sure the next device is going to require at least 4 or 6 GB of RAM. That’s the way it goes. Must be a law of nature :slight_smile:

4 Likes

It could be that I am observing app crashing as well as described in this thread: Android app background execution - #13 by tombln

The app (komoot) runs for a while in background, but at some point, when I reopen it, it appears to be freshly started/reset.

Would those be symptoms of crashed/forcefully stopped android apps? I have not yet found a way to have the app run for a longer time in the background, it reliably crashes/resets after around 15-30min in the background.
On a 10 ii that is.

I don’t have any other apps except Fernschreiber running, and on the android side only MicroG. So I am not sure how this could be caused by memory issues? What do you guys think? Is there a way I could figure out if it was caused by memory issues?
Maybe I could just start a bash loop which prints memory usage into a file every x seconds and see how it went during the crash?

2 Likes

Maybe you have the contactsd issue? Contact occupy RAM - together.jolla.com

Arghh, can’t edit original post to keep this info together.

Anyway, another full days usage and the worst figures I got were:

free -m
              total        used        free      shared  buff/cache   available
Mem:           3556        3089          53          27         412         446
Swap:          2047        1923         124

That was with deliberately heavy usage, 6 native + 6 big Android apps running.
No app crashes so far, but I have noticed some delays (1-2 seconds) switching between apps before the screen reloaded. Looking good so far with the extra 1GB swap. Could probably reduce it to 512MB, that would have been sufficient 90% of the time. Will keep going another couple days and then try increasing ZRAM and report findings back here.

Have the same Problem and it is anoying as hell! It happens not only once a day, that all apps or at least all android apps are closed while phone is laying arround. No Android, no Nextcloud talk messages are ariving anymore. You only get notice of it if you get a call, asking for response :confused:

4.2.0.21 does not make anything better!

Has someone reported this via zendesk? Maybe none of the responsible at Jolla is reading here…

Just wanted to document what I did on my Xperia 10 ii 4.3.0.12 in case it may help someone (thanks for all the information in your posts) :

dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 600 swapfile
mkswap /swapfile
swapon /swapfile

then edited “/vendor/etc/fstab.pdx201” to reduce zram to 500M and mount the swap file :

...
# ZRAM/SWAP          
/dev/block/zram0                           none                  swap     defaults     
/swapfile                                  none                  swap     sw              0       0
...

I find the result quite dramatic (positively) especially for android apps, and its seems to resist in time and reboots. 1GB swap is probably overkill though.

7 Likes

Thanks for sharing your experiences! Does the entry for the /swapfile really work for you on a reboot? Somehow in my case the swapfile does not get mounted on a XA2. The only difference is that I made the swap on /home/swapfile instead directly in root. Does this matter somehow?

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?