z-RAM Swap Manager

A versatile zRAM swap manager with dynamic swappiness – for Android and GNU/Linux systems.

Install/Upgrade

Android (Magisk module)
  Flash the zip or run su -c sh /path/to/install.sh [--start]

GNU/Linux
  sudo sh /path/to/install.sh [--start]

Uninstall

Android
  su -c /data/adb/modules/zram-swap-manager/uninstall.sh [[--stop] [--keep-config]]

GNU/Linux
  sudo zram-swap-manager-uninstall [[--stop] [--keep-config]]

Config

Android
  /data/adb/vr25/zram-swap-manager-data/config.txt

GNU/Linux
  /etc/zram-swap-manager.conf

Default Config

config_ver=202111230 # used for patching; do not modify!

comp_algorithm=auto # [auto] -> zstd (288) | lz4 (210) | lzo-rle (212) | lzo (211)
comp_ratio=210 # [210], irrelevant when comp_algorithm=auto
mem_percent=33 # [33], memory limit

dynamic_swappiness=true # [true], swappiness <--> /proc/loadavg
load_sampling_rate=60 # [60] read /proc/loadavg every x seconds
high_load_threshold=90 # [90], %
high_load_swappiness=80 # [80]
medium_load_threshold=45 # [45], %
medium_load_swappiness=90 # [90]
low_load_threshold=0 # [0], %
low_load_swappiness=100 # [100]

vm="swappiness=80 page-cluster=0"

# android's low memory killer (deprecated in favor of lmkd in recent OS versions)
# write /sys/module/lowmemorykiller/parameters/minfree "CUSTOM PARAMETERS GO HERE"

Terminal

Run zsm or zram-swap-manager for help.

Benchmarks

CompressorRatioCompressionDecompression
zstd 1.3.4 -12.877470 MB/s1380 MB/s
zlib 1.2.11 -12.743110 MB/s400 MB/s
brotli 1.0.2 -02.701410 MB/s430 MB/s
quicklz 1.5.0 -12.238550 MB/s710 MB/s
lzo1x 2.09 -12.108650 MB/s830 MB/s
lz4 1.8.12.101750 MB/s3700 MB/s
snappy 1.1.42.091530 MB/s1800 MB/s
lzf 3.6 -12.077400 MB/s860 MB/s

Notes/Tips

On some Android systems, one may want to delay initialization to ensure defaults and/or third party tweaks are overridden. This can be done by adding `sleep 90` or a more elaborate logic to config.

Download z-RAM Swap Manager Magisk Module

You can get the latest version of z-RAM Swap Manager by clicking the below link:

Latest Version

v2023.7.17

v2023.7.17 (202307170)

  • KernelSu support
  • Updated documentation
  • Various fixes & optimizations

Here’s all the available versions:

v2023.7.17

v2023.7.17 (202307170)

  • KernelSu support
  • Updated documentation
  • Various fixes & optimizations

v2022.1.9

v2021.12.2

v2021.11.23

Requirements

Installation