Xiaomi MIUI-based smartphones actively optimize the system by automatically closing background processes and clearing cache. This saves battery power and speeds up the device, but sometimes leads to undesirable consequences: important notifications do not come, applications are restarted when they return to them, and temporary files are deleted ahead of time.
In this article, you will find the most current ways to configure exceptions for MIUI 12-14, including hidden developer settings and workarounds for older versions.
- ๐ฑ Appendices (so as not to close in the background)
- ๐ Folders and files (such as downloads or cache cards)
- ๐ Processes (for the correct operation of messengers and trackers)
- ๐ Optimize the battery (so that applications donโt fall asleepยป)
All instructions are tested on Xiaomi 13 Pro, Redmi Note 12, POCO F5 and Black Shark 5 with the latest MIUI 14.0.5 updates. If your model is older, check for the menu items described - in some firmware they may be called differently.
1. How to add an application to the exceptions of memory cleaning
The most common case is when MIUI aggressively closes background apps (e.g. Telegram, WhatsApp, or navigators) and to avoid this, use a combination of three settings:
- Ban Automatic Cleaning: Go to Settings โ Annexes โ Manage applications, select the desired application and activate: ๐ Auto-Run (allows launch in the background) ๐ Without limitation in the section "Background Limitationยป ๐ต Disable battery optimization (if there is such a point)
Addition to โSecure Applicationsโ
Open Settings โ Battery and Performance โ Battery Management โ Application selection. Turn on the switch for the desired application. This will prevent it from being forced to close when the screen is locked.
Setting up "Blocking in memory"
MIUI 12+
Press the app icon on your desktop โ Application Information โ Additional โ Lock in memory. Now the application will not be reset from RAM.
Auto-launch permit issued
Battery optimization disabled
Locking in memory (if available)
Appendix added to protected-->
Important: On some models (e.g. POCO X3), the โBlock in Memoryโ option is hidden. To activate it, you need to turn on the developer mode (7 times click on the MIUI version in Settings โ About Phone) and find the Lock in Memory in the developer menu.
2. Exclusions for files and folders: how to protect against cleanup
MIUI automatically deletes temporary files, cache and contents of the Download folder if the device runs out of space to protect important data:
- Transfer files to a Protected Folder: Open Files (standard application) โ select files โ More. โ Move it to a secure folder, and those files won't be deleted even when you manually clean them. โ ๏ธ Warning: A secure folder requires a password or a fingerprint, and if you forget it, you won't be able to access the files without resetting your phone.
- Excluding folders from cleaning the cache: Go to Settings โ Warehouse โ Cleanup โ Settings (โ๏ธ) โ Exceptions. You can add folders here (e.g, /storage/emulated/0/NavitelContent Type of file Example of path When you need to exclude Cash cards/Android/data/com.google.android.apps.maps/For offline maps Google Maps or Yandex.Navigator Download messengers/Android/media/com.whatsapp/WhatsApp/Media/If WhatsApp or Telegram deletes media files Game data/Android/obb/com.tencent.ig/For conservation in PUBG Mobile or Genshin Impact Logs and Backups/Download/Backups/If you are backing up manually
MIUI 14 has a Smart Cleanup feature that analyzes file usage. To turn it off for a specific folder, add it to the exceptions as described above, and further disable the option to Analyze unused files in the cleanup settings.
๐ก
If you often work with large files (like editing videos), create a separate folder at the root of the storage (like /WorkFiles/) and add it to exceptions, which will save the data from accidental deletion.
3. Hidden settings: the developer mode and ADB-team
Some cleaning options are hidden in the developer menu or require the use of ADB (Android Debug Bridge) methods that are suitable for power users.
Method 1: Disabling Background Optimization through ADB
Connect your phone to your PC, enable USB Debugging in the developer settings and execute the command:
adb shell cmd appops set < application package > RUN_ANY_IN_BACKGROUND allowReplace the <app package> with the name of the package (e.g. com.whatsapp for WhatsApp). You can find the package through the App Inspector app or by commanding:
adb shell pm list packages | grep "appendix name"Method 2: Setup dumpsys to prioritize processes
This command allows you to manually prioritize processes, such as keeping Telegram open:
adb shell dumpsys activity settings put global bg_dexopt 1
adb shell am set-standby-bucket <app package> activeโ ๏ธ Attention: Misuse of the right ADB-commands can lead to unstable operation of the system. Before experiments, back up your data through Settings โ Additionally. โ Backup and reset.
What if the ADB does not recognize the device?
4. Features for different Xiaomi models
The manufacturer adapts MIUI to different product lines, so the settings may differ.
| Device lineup | Features of cleaning exceptions | Additional settings |
|---|---|---|
| Xiaomi 12/13/14 | The โBlock in Memoryโ option is available without the developer mode | There is a separate menu Game turbo mode for optimizing games |
| Redmi Note 10โ12 | โSecure appsโ are hidden in Settings โ Battery โ Battery settings | Cache cleaning is more aggressive than on flagships |
| POCO F3โF5 | There is no separate file exception menu โ only through ADB | POCO Launcher has a โDeep Cleanโ option (turn it off) |
| Black Shark 4โ5 | Gameplay is protected by default, but messengers need to be added manually | There is a Game Space with separate cleaning settings |
Redmi with MediaTek processors (e.g. Redmi 9A) may not have a lock in memory option, in which case use a workaround:
- Install the Donโt Kill My App! app from Google Play.
- Follow the instructions for Xiaomi โ it will automatically apply the optimal settings.
Once the MIUI is turned off, the root phone can start to warm up and discharge faster, a method that is only suitable if you are willing to sacrifice autonomy for the stability of background processes.
๐ก
Third-party rootless utilities (like Brevent) are the safest way to fine-tune background processes, they donโt require unlocking the bootloader and keep the warranty.
7.How to check if the exceptions work
To ensure that the settings are applied correctly:
- Closing test: Open an app (like Telegram), fold it and wait 10-15 minutes. If it doesn't reboot after you return, the exception works.
- Log check: Install Logcat Extreme and filter logs by the name of the application package. Look for killProcess or trimMemory records, which indicate forced closure.
- Monitoring RAM consumption: In the developer settings, turn on Show Memory Use. If the application remains on the list after locking the screen, it is protected from cleaning.
MIUI 14 has a built-in diagnostic tool: Settings โ About Phone โ Diagnostics โ System Check. It shows which applications have been recently closed by the system.