Xiaomi MIUI-based smartphones are known for aggressive memory optimization: the system automatically closes background processes and clears the cache of applications to save battery power and free RAM. However, this feature often deletes data from important programs such as messengers, navigators or games, which makes them longer to start, lose unsaved settings or even leave your account.
In this article, you will find the most current ways to protect applications from auto-cleaning on MIUI 12-15 (including HyperOS), and understand why some programs can still be closed by the system. We tested the instructions on the Redmi Note 12 Pro+, Xiaomi 13 Ultra and POCO F5 models β the methods work on all devices of the brand released after 2020.
Why Xiaomi is cleaning apps: the mechanism of auto-cleaning
The MIUI auto-cleaning function uses two key mechanisms:
- π Cache Clearing: The system deletes temporary application files (for example, downloaded images in messengers or maps in navigators) if they have not been used for a long time.
- β‘ Battery optimization: background processes are paused or shut down to reduce charge consumption.
- ποΈ Automatic Memory Cleanup: When RAM is lacking, the system forcibly closes applications, even if they are added to exceptions (but less often).
It is important to understand that adding exceptions does not guarantee 100% shutdown protection, it only reduces the probability. For example, if there is less than 200 MB of free memory left in the system, MIUI can ignore exceptions and force the background processes to be cleared.
Also, auto cleaning depends on the battery mode:
- π Balanced: Moderate optimization (recommended for most users).
- πΏ Charge savings: aggressive closing of background processes.
- β‘ Performance: Minimal optimization (but battery runs down faster).
β οΈ Note: On HyperOS devices (e.g. Xiaomi 14), the path to exception settings may be different. If you don't find Special Permissions, check the Apps section β Application management β Auto-start.
Method 1: Adding exceptions to security (MIUI 12β14)
This is the most reliable method for most devices, and the instructions are relevant for smartphones on MIUI 12-14, including Redmi 10/11, POCO X4/X5 and Xiaomi 12/13:
- Open the Security app (shield icon).
- Go to Optimization (or Acceleration on some firmware).
- Tap it on. βοΈ Settings in the upper right corner.
- Select the Cleanup Exceptions (or the Exclusion List).
- Click Add Apps and mark the desired programs.
Once added, the application will be protected from:
- π§Ή Automatic Cache Cleanup When Pressed Clean Up in the Optimization Menu.
- βΈοΈ Forced background closure (but not 100% β see the restriction section).
Is the application open in the background (check the latest task menu)
Are the settings not reset during reboot
Is the cache saved (for example, maps in Google Maps)
Does not appear notification "Application optimized"-->
If the application is not listed, make sure it is installed in the main memory of the phone (not on the phone). SD-Also, some system programs (e.g. Google Play Services) cannot be added to the exceptions.
Method 2: Setup autostart and background activity
Even if the application is added to the cleaning exceptions, the system can block its background operation, and to avoid this, you need to enable auto-start and allow background activity:
- Go to Settings β Applications β Application Management.
- Select the desired application (for example, Telegram or Yandex.Navigator).
- Slip it on Permission.
- Turn on the switches: π Auto-Run (allows the application to start when the phone is turned on). π± Background activity (allows work in the background). π No battery restrictions (disables optimization for this application).
π‘
If the permission list does not include Background Activity, try clearing the Security app cache (Settings β Apps β Security β Storage β Clear the cache) and restarting the phone.
On some firmware (e.g. MIUI 13 Global), the item No battery constraints may be called Battery Optimization β No restrictions. If it is not, then the application is already excluded from optimization.
Method 3: Using ADB for deep optimization (for advanced)
If standard methods donβt help (for example, the application still closes), you can manually disable optimization via ADB. This method is suitable for advanced users and requires connecting the phone to a computer.
You'll need:
- π₯οΈ Computer with installed ADB-Drivers (you can download from the Xiaomi website or through Android) SDK).
- π± Included Debugging by USB on the phone (Settings) β The phone. β Version. MIUI β Tap 7 times, then return to the additional β For developers).
- π USB-cable (preferably original).
Instructions:
- Connect the phone to the PC and confirm the debugging permission.
- Open the command line (Win + R β cmd) and type:
adb shell dumpsys deviceidle whitelist +com.example.packetReplace the exemplary package with a real application package (you can find it through the App Inspector or the APKMirror website). For example, for Telegram, the command will:
adb shell dumpsys deviceidle whitelist +org.telegram.messengerTo check the list of excluded applications, use:
adb shell dumpsys deviceidle whitelistβ οΈ Attention: Misuse of the right ADB Do not add system applications (e.g. com.miui.securitycenter) to the exceptions unless you understand the consequences.
How to find out the application package without third-party programs?
Limitations and nuances: why apps are still closed
Even after adding an exception, some applications may close, and here are the main reasons:
| Problem. | Reason. | Decision |
|---|---|---|
| The application closes when the screen is blocked | Charge Saving or Deep Optimization Mode Enabled | Switch to Balanced Mode in Settings β Battery |
| Cash clears after reboot | The system forcibly clears memory at low RAM | Close unnecessary applications manually or increase the amount of RAM (some Xiaomi models support virtual memory expansion) |
| Notifications don't come in the background | Auto Start or Background Activity Disabled | Check permissions in Settings β Applications β Application Management |
| The application is not retained in exceptions | Restricted firmware (e.g. MIUI Global for Europe) | Update the software or use ADB (see Method 3) |
Another important nuance: on HyperOS devices (such as Xiaomi 14 or Redmi K70), the optimization algorithm has changed. Now the system analyzes user behavior β if you rarely open an application, it can be excluded from the background even despite the settings.
Cleaning up the app cache
Closing of background processes
Optimizing the battery
Nothing. Everything's fine.-->
How to check if the exception works
To make sure that the application is truly protected from cleaning, follow the following steps:
- Cache Clearing Test: Open the app (like Google Maps) and download the maps. Close it and run the optimization manually (Security β Clean). Open the app again - if the cards load quickly, the exception works.
- Background test: Send yourself a message in a messenger (like Viber), close the app and wait 10-15 minutes. If the notification comes, background activity is not blocked.
ADB
adb shell cmd appops query --user 0 Package applicationsLook for lines RUN_ANY_IN_BACKGROUND and RUN_IN_BACKGROUND β They must have the status of allow.
If the tests fail, repeat setting exceptions or try alternative methods (e.g. ADB).Some firmware (e.g. MIUI China) may need to disable MIUI Optimization in the developer settings.
Alternative methods: if nothing helps
If the standard methods donβt work, try these solutions:
- π§ Shutdown MIUI Optimization: Activate Developer Mode (7 taps according to version) MIUI). Go to Settings. β Additionally. β For developers, find a point. MIUI Optimization and turn it off. Reboot the phone.
β οΈ Note: Disabling this feature may cause some system applications to work unstable (e.g. Topics or Security).
Use of third-party utilities
Applications like Greenify or Brevent allow you to manually manage background processes, but they require root rights or ADB.
Transition to custom firmware
AOSP-based firmware (such as LineageOS or Pixel Experience) does not have aggressive MIUI optimization.
For devices on HyperOS (for example, Xiaomi 14) there is another way - the "No Limits" mode for the battery:
- Go to Settings β Battery β Battery Optimization.
- Select the application and set the No Limits mode.
π‘
On HyperOS devices, battery settings are prioritized, not clean-up exceptions. Always check both sections!