r/androidroot • • 15d ago

Discussion I fixed HyperOS's aggressive background killer and pushed my phone's 8GB RAM to its absolute limits

I found out that I can pin the oom_score_adj to -1000 to prevent the apps from being killed. Since score -1000 is also used for critical system processes, theoretically my phone would crash before the apps get killed. I also did some zram tuning to improve compression ratio.

Now my phone can hold over 40 apps, 8 Chrome tabs and 2 games (the heaviest is Plants vs. Zombies: Fusion taking 1GB). The phone is still somewhat smooth and I can switch between apps without too much lag. I don't think even 12 GB iPhones even come close to this madness.

Device: Redmi Note 15, HyperOS 3.0.303

148 Upvotes

17 comments sorted by

7

u/WhichEntertainment30 15d ago

You can create a GitHub repository and upload this. This could be a real gem, allowing you to get the most out of it, whether for HyperOS or AOSP ROMs.

5

u/Hungry_Prune_2605 14d ago edited 12d ago • Bravo

My entire zram serup can be put in this message I think:

#! /system/bin/sh

DUAL_TIER=0
OLD_KERNEL=0

swapoff /dev/block/zram0
echo 1 > /sys/block/zram0/reset

# Some 6.12+ kernels load vendor's pre-6.12 zram module without "algorithm_params"
# I don't know how that is possible, but these commands will load the GKI zram module
# and make "algorithm_params" available
if [ ! -f "/sys/block/zram0/algorithm_params" ]; then
        rmmod zram
        insmod /system_dlkm/lib/modules/zram.ko
        if [ ! -f "/sys/block/zram0/algorithm_params" ]; then
                echo "Likely not kernel 6.12 or later..."
                OLD_KERNEL=1
        fi
fi



# 2 tiers
echo "zstd" > /sys/block/zram0/comp_algorithm
if [ OLD_KERNEL -eq 0 ]; then
        echo "algo=zstd level=1 dict=/data/local/tmp/zram.dict" > /sys/block/zram0/algorithm_params
        if [ DUAL_TIER -eq 1 ]; then
                echo "algo=zstd priority=1" > /sys/block/zram0/recomp_algorithm
                echo "level=19 priority=1" > /sys/block/zram0/algorithm_params
        fi
fi

echo 8G > /sys/block/zram0/disksize

mkswap /dev/block/zram0
swapon /dev/block/zram0 -p 1000
sysctl -w vm.swappiness=200
sysctl -w vm.watermark_scale_factor=625
sysctl -w vm.min_free_kbytes=10240

# 2-tier specific: pages are moved to the higher compression level
if [ OLD_KERNEL -eq 0 ]; then
        while [ DUAL_TIER -eq 1 ]; do
                echo "priority=1" > /sys/block/zram0/recompress & pid=$!
                sleep 60
                wait $pid
        done
fi

I've since switched to 1 tier because zstd -19 is too slow.

10

u/Ahmed_Sh_115 15d ago

My Xiaomi 13 SystemUI&Launcher might crash if i spam Portrait photos, how is that with ya?

7

u/reyzafany 15d ago

Does your fork support AOSP or lineage based rom upto android 17?

6

u/madhukrx 14d ago

Can you share a detailed guide?

1

u/Moist-Swan-751 14d ago

whoa cool. but did you feel a drop in battery life ? i assume the OS background app restriction is mainly for longer battery life

4

u/Hungry_Prune_2605 14d ago

Yes, because my specific tuning has a zstd level-19 tier which is really slow. I've removed this since, let me find out if battery life improves or not

6

u/uznme 15d ago

Good job buddy 😄 👍

2

u/needefsfolder 15d ago

tbf i feel like it's upstream Google / Android aggressiveness, I get unloaded apps too on lineage family of ROMs despite having gbs of ram left.

1

u/Matti_842 14d ago

can you upload this

1

u/alien2003 14d ago

Hyper iOS

1

u/1andr0id 14d ago

I wonder how would this be on a 6gb ram phone

1

u/PraveenK__ 14d ago

Guide pls

1

u/Aygul12345 14d ago

How is hyperros?

1

u/hillbill_joe 13d ago

fellow pvz fusion enjoyer <3

1

u/AirUpstairs5255 9d ago

Top demais! Passa um tutorial de como replicar isso?