[Redmi 9A ROMs, Kernels, Recoveries, & Other Develo] XTos24:
I just wanted to share that I finally managed to solve this "complete-app-reload-on-returning" issue on my LOS v20.0..!

Well it wasn't easy at all... :ROFLMAO:

But besides that the basic lag of this ROM remained the same...

It reacts to taps after 1-2 sec, and even after that it reacts slower then the 32 bit LOS v19.1 version...

I don't know why, I thought a 64 bit OS will be better.

Maybe it's beacause my 9AT has just 2GB RAM, I don't know.

As I checked the system from the background with adb shell and the "top" command while I used my phone it turned out that the "kswapd" process works a lot even when there are almost the same memory conditions as on the 32 bit version... :cautious:

Maybe that can be solved as well, I don't know... Some Linux-pro-bro could help us... :)

The milestones in my "apps-please-do-not-reload" quest:

as it turned out in Android there is a user space deamon which manages the (low) memory related tasks (kill) based on a lot of properties

it is called LMKD (aka "Low Memory Killer Daemon...)

and here are the properties to fine tune it's behaviour

but of course it's not so easy just to set these in some files...

my problems were:

I tried to write them to the /system/build.prop but this file resets on boot (from /system_root)

so I had to boot into recovery and mount it in "rw" mode

mount -o remount,rw /system_root

then I could push my version like this:

adb push system_build.prop /system_root/system/build.prop

(I'll share my trial LMKD configs below...)

but before that it turned out that 2 props are already defined somewhere else:

ro.lmk.psi_complete_stall_ms=70
ro.lmk.swap_free_low_percentage=10

after a bit of search I found that they are defined here: /vendor/build.prop

so I tried to remount /vendor in "rw" mode as well:

mount -o remount,rw /vendor

and push the file but I got an error message that there is "No space left on device"...

after some research it turned out that there is a special "super" partition in Android 11 that is a compose and has a lot sub-partitions dynamically like "/vendor" for example and are basically read-only partitions + even if I remount them "rw" they are sized to 100% so even a few byte modification can't be done...

so the next step to solve this was to install Magisk with the module: "RO2RW"

this tool can solve exactly this problem: it can resize these sub-partitions and mount them in "rw" mode...

here is the XDA guide I followed with success

after that finally I could remove the 2 LMK line from the vendor.prop and so add the new ones in 1 place: into my system buid.prop...

And here are the LMK props which I played with (at the end of /system_root/system/build.prop modified in recovery mode):

###########################################
# LMK #####################################
###########################################
#ro.lmk.debug=true
ro.config.low_ram=false
ro.lmk.use_minfree_levels=false
ro.lmk.use_psi=true
ro.lmk.downgrade_pressure=25
ro.lmk.psi_partial_stall_ms=4000
ro.lmk.psi_complete_stall_ms=14000
ro.lmk.thrashing_limit=5
ro.lmk.thrashing_limit_decay=90
#ro.lmk.swap_util_max=30
ro.lmk.swap_free_low_percentage=10
# end of file

But you can play with them as well, it's fun..! :D

One important note I experienced through the trials:

Right after the boot, the system needs a few minutes to settle...

If you test your new values in this period it can be a bit misleading.

So wait a few minutes to try the real effect...

I tested my values with starting 3-4-5 bigger apps like GMail, a wheather app, Google News, Camera, Settings and switched between them. I tried to switch without going to the "Desktop" ("starting screen"?) and with going to the Desktop, and without/with locking the Screen, etc.

Also when locking the screen I waited a few minutes and then went back and see whether my last app in the foreground was reloaded or not... and then the other apps, etc...

I managed to achieve that 4-5-6 apps did not reload, even after going to the "Desktop", even after locking the screen, and ever after waiting a few minutes...

Of course after more time there was some reload but that can be already at app level I guess... But the app in the foreground almost never reloaded...!

You can also try the "ro.config.low_ram=true" mode as well and tweak all the other values as well to see what works for you the best.

I didn't understand all the official explanations for all of the props, so half of it was just a trial and error process... :giggle:

And I almost forget to mention that this whole journey started here:

GitHub - lululoid/meZram: Performace tweaks for multitasking and gaming. Set custom tweak for individual app, add SWAP, resize ZRAM. With aggressive mode able to improve FPS and reduce lag.

Performace tweaks for multitasking and gaming. Set custom tweak for individual app, add SWAP, resize ZRAM. With aggressive mode able to improve FPS and reduce lag. - lululoid/meZram

github.com

Here are some good examples for these props and values.

(I didn't try this Magisk module as my banking app detects Magisk...

I just used it to the RO2RW process and then removed it completely...)