Set Activity Manager's max. cached process number to 256 (instead of the default 32 (or even lower 24.. Pixel has 64) and
Set phantom processes to the max. possible value to prevent their unintentional killing
Disable PeriodicCleaner which is a MIUI "feature"..
https://gist.github.com/agnostic-apollo/dc7e47991c512755ff26bd2d31e72ca8
## Android 9 and below:
settings put global activity_manager_constants max_cached_processes=256
## Android 10 and above:
/system/bin/device_config put activity_manager max_phantom_processes 2147483647
/system/bin/device_config put activity_manager max_cached_processes 256
## Combined:
[ $(getprop ro.build.version.release) -gt 9 ] && /system/bin/device_config put activity_manager max_phantom_processes 2147483647 ; /system/bin/device_config put activity_manager max_cached_processes 160 || settings put global activity_manager_constants max_cached_processes=160