[Xperia X] Lack of swap, apps get killed
On my Xperia X (SFOS 2.1.3.7) I noticed that there is no swap at all. I always thought that no swap at all was a bad idea in general, and now after using the phone for a few weeks I've experienced some cases where apps would be unexpectedly killed, usually just the browser but sometimes some android apps as well, when for example loading a heavy webpage. On JollaC this almost never happened to me, so it's strange that a device with more RAM has this problem.
For example the Peacekeeper browser test (http://peacekeeper.futuremark.com/) always crashes at the fourth testing sequence. (see edit)
To check if the lack of swap was really the culprit, I created a 1GB swap file in my home directory. After enabling the swap I ran the Peacekeeper test and this time it succeeded to finish the whole test. During the test around 450MB of swap was used. Another test with the swap disabled caused browser to be killed again, and once swap was enabled it went straight through, again. So my conclusion is that swap should be enabled for the Xperia X to ensure stability of the system/apps in heavy usage.
IIRC there isnt a swap-partition, the system-partition is too small for swap, and creating a new swap-partition is highly risky. But this can be solved by creating a swap-file in the home-partition which has the most space. 512MB or maybe even smaller (<400mb on JollaC) swap file is probably enough, so its not a huge sacrifice for the stability. Any thoughts?
edit. I had quite a lot of apps (my normal usage) open when I had the browser crash on the fourth sequence. On a fresh boot without other apps the total RAM usage is of course smaller and this test will not be enough to fill the RAM & kill the browser. So the testing method is not the best, but you get the point.
I'm using Opera as browser and it have been killed couple times. I don't know the reason but I'd like to test this swap-file and see if it helps. Can I use the method described in ArchWiki for creating the swap-file?
kaappikello ( 2017-11-14 22:22:14 +0200 )editYes, you can use those instructions, but I wouldnt touch the /etc/fstab file unless I knew exactly what I was doing. You can experiment with the swap without touching fstab.
synthent ( 2017-11-14 23:25:28 +0200 )editHow about using zram device instead of storage space? Zram is compressed so it actually saves you more memory than what it uses. As
devel-su
run:It allocates 512 MB of swap with compression. Double the amount if you still run out of memory.
Reboot when you want it back to normal. Or one can also first run swapoff /dev/zram0 and then zram -r /dev/zram0, if I remember it correctly.
Manatus ( 2017-11-15 09:55:52 +0200 )editI fear there might be also a memory leak in lipstick. However you need very long runtime to achieve that. However I can achieve that big memory usage in lipstick on the tablet everytime which causes crashes of the browser. Restarting lipstick and voila browser does not crash anymore. (I mean crash not OOM Killing)
The SWAP on Sailfish X needs to be turned on. It should be at least 1 GB (using ZRAM with LZ4 compression [which is default] this should be possible without issues)
The Sailfish-Browser btw. crashes also not only because of RAM usage sometimes on the Xperia X. I guess it has to do with the graphics driver still being not fully optimized.
leszek ( 2017-11-15 12:41:56 +0200 )editThanks for the tip about how to setup zram. I will now test it for a while and see if I will run into anything strange.
edit. Swap file seems unnecessary (plus has risks pointed out by Cmdr_Zod) so zram only is probably the best way to have swap enabled.
synthent ( 2017-11-15 18:13:31 +0200 )edit