I am using a device with 2 GB of ram (Nexus 7 2013) and I experienced frequently that apps are killed. Quite often it gets so bad that it's impossible to have both dekko and the browser open at the same time. It always felt like it was an out of memory situation. Today I stumbled over this remark of ShadowEO on his github page to configure the lowmemorykiller. In my experience, I need two other tweaks in addition. So in total I did the following three things:
- Increase the swappiness
dstat --top-oom --top-mem --vmstat -s 30
tail -f /var/log/syslog | grep sigkill
cat /proc/sys/vm/swappiness 0 echo 70 | sudo tee /proc/sys/vm/swappiness
- Increase swapspace
Now the swap is being used, but it doesn't seem to make a whole lot of a difference with the killing, so I increase the size of the swapspace.
Out of the box, if I remember it correctly, I only had 32 MB of swap:
sudo swapoff /userdata/SWAP.img sudo rm /userdata/SWAP.img sudo fallocate -l 2g /userdata/SWAP.img sudo mkswap /userdata/SWAP.img sudo chmod 0600 /userdata/SWAP.img sudo swapon /userdata/SWAP.img
- Configure the lowmemorykiller
Now a little more of the swap is being used, but it still doesn't stop the killing. Seems on Android there is something called lowmemorykiller, which on my Nexus 7 had this original configuration:
cat /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,16384
echo "1536,2048,4096,5120,10240,15360" | sudo tee /sys/module/lowmemorykiller/parameters/minfree
With all three things in place, I can now have the browser, dekko, podbird, filemanager, unav, uradio playing music, terminal and gedit and libreoffice writer running from libertine all open at the same time. I'm almost running out of apps that I care to run in addition
At times there was some stuttering, but of course nobody forces you to have so many apps open at the same time. However, now you can choose what you want to close to relieve the memory pressure Swappiness and lowmemorykiller I need to repeat after every reboot. Need to find a solution to persist this.
I'd be curious to hear whether/how this works for other people!