[trick] Reduce system memory usage

shadowchaos

Senior Member
Mar 10, 2011
67
20
0
It takes half of the total memory by system itself for 4gb ram phones .
That's left only 1~1.5gb if some user servers app.
It greatly reduces mutil-task abilities for 4gb ram phones.Once I thought :victory: for 4gb.

The memory took by system cannot be released by mutil-apps ,apps that just kill processes to each other.But it can be released by single one large memory starved app, like games.

That inspired me to find a way that easy to reproduce.
By searching some,I found this one:
https://unix.stackexchange.com/questions/99334/how-to-fill-90-of-the-free-memory/99435#99435

The answer "tail /dev/zero" did the trick.

On android,I use Termux to execute this command.
With the combination of totalcommander , it can be done easier.
In totalcommander ,add a new 'sh command' :
Code:
am start -n com.termux/com.termux.app.TermuxActivity
sleep 1
input text 'tail /dev/zero'
input keyevent 66
exit the termux, wait a few seconds, it should be done for you.

If you look at the "running servers" in developer mode,you'll see that system's memory usage shrinks down to 700+mb.And of course not that low , it will take up to 1.3gb around.
After a month observation, it all works well for released about 500mb from system.

This command not only releases system memory,but also releases ui resources of user server apps. So I recommend that starting all user service apps including servers by termux , then execute this command.
(This command will not kill servers hold by termux , but "</dev/zero head -c 4000m | pv | tail" this one will. So,the better choice is the "tail /dev/zero")

For better multi-task experience, also recommend to set /sys/module/lowmemorykiller/parameters/minfree to
2048,4096,8192,16384,24576,32768
That's 8mb,16mb,32mb,64mb,96mb,128mb in app kernel adiutor.
(set enable_adaptive_lmk to 0 and vmpressure_file_min to 33280 (130mb) too)