Linux 3.15 added a Mac-like function, memory compression zram, and a zswap, Zram is usually placed in a module in the system, so that can be customized according to the needs of the load.
Raspberry Pi3 1g Memory capacity is too small, set the Zram can squeeze a bit of memory, android4.4 data seems to be 40%.
Paste code (copied from desktop Ubuntu)
Setup code:
#!/bin/SH# Load Dependency modulesnrdevices=$(grep-C ^processor/proc/cpuinfo |sed 's/^0$/1/')ifModinfo Zram |grep-Q'zram_num_devices:' 2>/dev/NULL; ThenModprobe_args="Zram_num_devices=${nrdevices}"elifModinfo Zram |grep-Q'num_devices:' 2>/dev/NULL; ThenModprobe_args="Num_devices=${nrdevices}"ElseExit1fimodprobezram $MODPROBE _args# Calculate memory to use forZram (1/2of RAM) Totalmem= ' Lc_all=c Free|grep-E"^mem:"|sed-E'S/^mem: *//'-E's/*.*//'' Mem=$ (((Totalmem/2/${nrdevices}) *1024x768) # Initialize the devices forIinch$(seq${nrdevices}); DoDevnumber=$ ((I-1)) Echo$mem >/sys/block/zram${devnumber}/disksize Mkswap/dev/Zram${devnumber} swapon-P5/dev/Zram${devnumber} Done
To close the code:
#!/bin/shif devices=$ (grepawk'{print $}' then-in does swapoff $i donefi rmmod Zram
If you want to turn on the settings, just add the code to the/etc/rc.local, the boot automatically set
Startup or not can be viewed using the following command:
Swapon-s
The output is as follows
Filename Type Size used priority/DEV/ZRAM0 partition 118464 0 5/dev/zram1 partition 118464 0 5/dev/zram2 Partition 118464 0 5/dev/zram3 partition 118464 0 5
You can see that the number of 4 and processor is the same, the total is half of the total usable physical memory, as for why the processor number is better, the reason is unknown
[Raspberry Pi3] Zram settings