├── skip_mount ├── META-INF └── com │ └── google │ └── android │ ├── updater-script │ └── update-binary ├── system └── placeholder ├── customize.sh ├── system.prop ├── module.prop ├── uninstall.sh ├── service.sh └── README.md /skip_mount: -------------------------------------------------------------------------------- 1 | #skip_mount 2 | -------------------------------------------------------------------------------- /META-INF/com/google/android/updater-script: -------------------------------------------------------------------------------- 1 | #MAGISK 2 | -------------------------------------------------------------------------------- /system/placeholder: -------------------------------------------------------------------------------- 1 | This file will be deleted in Magisk Manager, it is only a placeholder for git 2 | -------------------------------------------------------------------------------- /customize.sh: -------------------------------------------------------------------------------- 1 | ui_print "" 2 | ui_print "################################" 3 | ui_print "# #" 4 | ui_print "# crok's RAM management tweaks #" 5 | ui_print "# #" 6 | ui_print "################################" 7 | ui_print "" 8 | 9 | -------------------------------------------------------------------------------- /system.prop: -------------------------------------------------------------------------------- 1 | # Tweak the memory management of the device, enable more background apps.. et cetera.. 2 | ro.sys.fw.bg_apps_limit=128 3 | ro.vendor.qti.sys.fw.bg_apps_limit=128 4 | ro.vendor.qti.sys.fw.bservice_enable=true 5 | ro.vendor.qti.sys.fw.bservice_age=10000 6 | ro.vendor.qti.sys.fw.bservice_limit=128 7 | -------------------------------------------------------------------------------- /module.prop: -------------------------------------------------------------------------------- 1 | id=crokrammgmtfix 2 | name=RAM management fixes by crok - ActivityManager's cached app number increaser + BService number increaser 3 | version=v0.0.8.1 4 | versionCode=8 5 | author=crok 6 | description=RAM management fixes by crok - ActivityManager's cached and empty app number increaser, empty timeout increaser, MIUI PeriodicCleaner disabler.. 7 | -------------------------------------------------------------------------------- /META-INF/com/google/android/update-binary: -------------------------------------------------------------------------------- 1 | #!/sbin/sh 2 | 3 | ################# 4 | # Initialization 5 | ################# 6 | 7 | umask 022 8 | 9 | # echo before loading util_functions 10 | ui_print() { echo "$1"; } 11 | 12 | require_new_magisk() { 13 | ui_print "*******************************" 14 | ui_print " Please install Magisk v20.4+! " 15 | ui_print "*******************************" 16 | exit 1 17 | } 18 | 19 | ######################### 20 | # Load util_functions.sh 21 | ######################### 22 | 23 | OUTFD=$2 24 | ZIPFILE=$3 25 | 26 | mount /data 2>/dev/null 27 | 28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk 29 | . /data/adb/magisk/util_functions.sh 30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk 31 | 32 | install_module 33 | exit 0 34 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | # Delete / reset Activity Manager's variables set by the module and system will use the Activity Manager's default settings after a restart: 4 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config set_sync_disabled_for_tests none 5 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config delete activity_manager max_cached_processes || settings delete global activity_manager_constants 6 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config delete activity_manager max_phantom_processes 7 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd settings reset global settings_enable_monitor_phantom_procs 8 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config delete activity_manager max_empty_time_millis 9 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd settings delete global settings_enable_monitor_phantom_procs 10 | 11 | echo "Please restart the device to make sure RescueParty and RollbackManager restore the default settings." 12 | -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | # Virtual memory tweaks - not really needed anymore 3 | # stop perfd 4 | # echo '100' > /proc/sys/vm/swappiness 5 | # echo '0' > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk 6 | # echo '100' > /proc/sys/vm/vfs_cache_pressure 7 | # echo '128' > /sys/block/mmcblk0/queue/read_ahead_kb 8 | # echo '128' > /sys/block/mmcblk1/queue/read_ahead_kb 9 | # echo '8000' > /proc/sys/vm/min_free_kbytes 10 | # echo '0' > /proc/sys/vm/oom_kill_allocating_task 11 | # echo '5' > /proc/sys/vm/dirty_ratio 12 | # echo '20' > /proc/sys/vm/dirty_background_ratio 13 | # chmod 666 /sys/module/lowmemorykiller/parameters/minfree 14 | # chown root /sys/module/lowmemorykiller/parameters/minfree 15 | # echo '21816,29088,36360,43632,50904,65448' > /sys/module/lowmemorykiller/parameters/minfree 16 | # rm /data/system/perfd/default_values 17 | # start perfd 18 | # sleep 20 19 | 20 | # Set Activity Manager's max. cached app number -> 160 (instead of the default 32 (or even lower 24): 21 | # Disable MIUI's periodic cleaner service (PeriodicCleaner - check your logcat..) 22 | # Obviously will throw an error if periodic service doesn't exist 23 | # but at the moment I'm a bit lazy to implement proper SDK testing and exception handling.. 24 | # In case it throws an error - it just doesn't exist / won't work. Sorry -.-' 25 | sleep 180 26 | 27 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config set_sync_disabled_for_tests persistent 28 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config put activity_manager max_cached_processes 256 || settings put global activity_manager_constants max_cached_processes=256 29 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config put activity_manager max_phantom_processes 2147483647 30 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd settings put global settings_enable_monitor_phantom_procs false 31 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd device_config put activity_manager max_empty_time_millis 43200000 32 | [ $(getprop ro.build.version.release) -gt 9 ] && cmd settings put global settings_enable_monitor_phantom_procs false 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Android RAM management fixes by crok - Magisk 20.4+ 2 | 3 | ## Activity Manager cached app number increaser + BService number increaser 4 | 5 | ## Find every info here: 6 | 7 | ## Telegra.ph posts by crok 8 | https://telegra.ph/Telegraph-posts-by-crok-05-28 9 | 10 | ## Related documents: 11 | 12 | ## Xiaomi Redmi Note 4X and memory management 13 | https://telegra.ph/Xiaomi-Redmi-Note-4X-and-memory-management-05-28 14 | 15 | ## Fine tuning an Android system 16 | https://telegra.ph/Fine-tuning-an-Android-system-04-20 17 | 18 | ## Details 19 | 20 | First of all: this is not a "classic" Magisk module. 21 | This is a set of commands to apply to modify the ActivityManager's behavior and disable MIUI PeriodicCleaner - but not systemless.. and not changing any files.. it is changing / adding system parameters when installed (and after reboot) and removes them when uninstalled. 22 | The values can be changed via ADB, too, so in case you want to apply the changes you can run the content of service.sh and in case you want to remove them you can run the content of uninstall.sh (Everything is [written here, too](https://logout.hu/bejegyzes/crok/android_activitymanager_am_es_memoriahasznalat_jav.html), it's hungarian but hope you get what the commands are doing - if you don't please don't go further!) 23 | 24 | ~~## Virtual memory "tweaks" -- kind of obsolate since Android 10..~~ 25 | ``` 26 | # Virtual memory tweaks 27 | stop perfd 28 | echo '100' > /proc/sys/vm/swappiness 29 | echo '0' > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk 30 | echo '100' > /proc/sys/vm/vfs_cache_pressure 31 | echo '128' > /sys/block/mmcblk0/queue/read_ahead_kb 32 | echo '128' > /sys/block/mmcblk1/queue/read_ahead_kb 33 | echo '8000' > /proc/sys/vm/min_free_kbytes 34 | echo '0' > /proc/sys/vm/oom_kill_allocating_task 35 | echo '5' > /proc/sys/vm/dirty_ratio 36 | echo '20' > /proc/sys/vm/dirty_background_ratio 37 | chmod 666 /sys/module/lowmemorykiller/parameters/minfree 38 | chown root /sys/module/lowmemorykiller/parameters/minfree 39 | echo '21816,29088,36360,43632,50904,65448' > /sys/module/lowmemorykiller/parameters/minfree 40 | rm /data/system/perfd/default_values 41 | start perfd 42 | sleep 20 43 | 44 | ``` 45 | 46 | THIS is still quite handy though! 47 | https://gist.github.com/agnostic-apollo/dc7e47991c512755ff26bd2d31e72ca8 48 | Credits goes to https://github.com/agnostic-apollo/ and all who were involved. 49 | 50 | ``` 51 | # Set Activity Manager's max. cached app number -> 160 (instead of the default 32 (or even lower 24): 52 | # https://gist.github.com/agnostic-apollo/dc7e47991c512755ff26bd2d31e72ca8 53 | ## Android 9 and below: 54 | settings put global activity_manager_constants max_cached_processes=160 55 | ## Android 10 and above: 56 | /system/bin/device_config put activity_manager max_phantom_processes 2147483647 57 | /system/bin/device_config put activity_manager max_cached_processes 160 58 | 59 | ## Combined: 60 | [ $(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 61 | ``` 62 | 63 | ## Android 9 and below: Increasing ActivityManager's cached app number + number of BService processes 64 | Obsolate - removed - in case you need them you can use MagiskHidePropsConfig to add them systemlessly (or simply add them to build.prop): 65 | ``` 66 | ro.sys.fw.bg_apps_limit=128 67 | ro.vendor.qti.sys.fw.bg_apps_limit=128 68 | ro.vendor.qti.sys.fw.bservice_enable=true 69 | ro.vendor.qti.sys.fw.bservice_age=10000 70 | ro.vendor.qti.sys.fw.bservice_limit=128 71 | ``` 72 | 73 | 74 | These can be easily set via other tools or apps that support init.d scripts and build.prop editing but I use Magisk anyway.. so.. why not using it to do the job properly - with successful SafetyNet test ( : 75 | 76 | 77 | *NOTE: If you are using MIUI ROM you may have to disable MIUI optimization and MIUI memory optimization because it resets most of these settings. If you use any app that tweaks settings above please uninstall or at least disable them to run and ruin the module's settings. Disabling MIUI opt. may cause permission and other kind of strange issues (like inability to attach files, etc). So.. I did tell you about it.* 78 | 79 | 80 | 81 | _Quite honestly speaking I wrote this for myself only, 82 | publicated long time ago and.. haters, please don't ever even install it, 83 | I'm not advertising this module anywhere so please use other mods, hyped high AF. 84 | This one is not doing fine-tuning by dynamic smart scripting or anything, 85 | just my own oldschool settings coming from my of Android and Linux experiences.. 86 | I tried to document everything, if you disagree with any of the settings then either 87 | do not install the mod or fork it and set it to your own value - freedom to do it is yours, too. 88 | This module is rather a proof of concept for myself than a module for everybody. It works very well for me._ 89 | --------------------------------------------------------------------------------