Have you noticed that your favorite application suddenly closes or restarts when switching between tasks? This is due to the Androidmemory management mechanism, which automatically preempts background processes to free up resources. The problem is especially pressing for devices with 2-4 GB of RAMwhere the system aggressively optimizes memory consumption. But what if you need the messenger, music player or navigator to work in the background without restarting?

In this article we will analyze 7 proven methods - from standard settings to advanced tricks with ADB and modification of system parameters. It's important to understand that some methods require root access or technical knowledge, while others work on any device without compromising your warranty. We will also explain why on new versions of Android (12+) classic methods with process limitation may not workand what to do about it.

Why Android unloads applications from memory

The operating system Android uses a mechanism Low Memory Killer (LMK) โ€”a special kernel driver that monitors free memory. When there is little of it left, LMK forcibly closes processes by priority:

  • ๐Ÿ”ด Background (invisible to the user, for example, mail synchronization)
  • ๐ŸŸก Service (music in the player, downloading files)
  • ๐ŸŸข Visible (minimized applications that you recently used)
  • ๐Ÿ”ต Active (current application on the screen)

On devices with 6+ GB of RAM LMK works less often, but even flagships are not immune from unloading - it all depends on manufacturer (for example, Xiaomi and Realme aggressively clean background processes in their shells MIUI and Realme UI). Key factors influencing unloading:

Factor Impact on unloading
Amount of RAM Less than 4 GB - upload more often, especially with multitasking
Android version Starting with Android 8.0 restricted background services
Manufacturer and shell Samsung One UI spares background services processes, but ColorOS no
Energy saving settings The "Battery Saver" or "Super Saving" modes kill background tasks

โš ๏ธ Attention: On some devices (for example, Huawei s EMUI) even disabling battery optimization does not guarantee stable operation of background applications. This is due to the deep integration of proprietary memory management algorithms.

๐Ÿ“Š What model of smartphone do you have?
Samsung
Xiaomi
Huawei
Realme/Oppo
Other

Method 1: Disabling battery optimization for an application

The safest and most universal method is to exclude the application from the list of optimized ones. This prevents the system from forcing it to close. The instructions are relevant for Android 6.0+:

  1. Open Settings โ†’ Applications.
  2. Select the desired application (for example, Telegram or Google Maps).
  3. Tap on Battery (or Battery optimization).
  4. Select Do not optimize or No restrictions.

On some devices (for example, Samsung), the path may be different:

Settings โ†’ Device maintenance โ†’ Battery โ†’ Three dots (โ‹ฎ) โ†’ Settings โ†’ Optimize application performance โ†’ Select application โ†’ Disable

โš ๏ธ Attention: On Android 12+ this method may not work for applications that use background services (for example, instant messengers with notifications). In this case, a combination with other methods will be required.

โ˜‘๏ธ Checking battery optimization

Done: 0 / 4

Method 2: Fixing the application in multitasking (for Android 10 and below)

On older versions Android (up to the 11th inclusive) there was a "Pin" function (Pin), which prevented the minimized application from unloading. How it works:

  1. Open the application you want to pin.
  2. Click on the square button (multitasking).
  3. Swipe up on the application card and hold - a pin icon will appear.
  4. Confirm the action.

โš ๏ธ Attention: On Android 11+ this function was removed due to changes in security policy. Instead, manufacturers have implemented their own solutions (for example, Samsung offers "Block in multitasking" in One UI).

For devices Xiaomi s MIUI there is an alternative:

Settings โ†’ Accessibility โ†’ Pinning applications โ†’ Enable
What to do if there is no "Pin" option

On some firmware (for example, ColorOS) this function is hidden. Try using it. data-i="130">-command: ADB-command: adb shell settings put global lock_to_app_enabled 1

After that, reboot the device and check for the option in the multitasking menu.

Method 3: Using ADB to change the priority of a process

If standard methods do not help, you can manually increase the priority of the application via ADB (Android Debug Bridge). This method does not require root, but requires USB debugging. Instructions:

  1. Enable Developer mode (tap the build number 7 times in Settings โ†’ About phone).
  2. Activate USB debugging in the developer settings.
  3. Connect the phone to the PC and run the command:
    adb shell am set-inactive  false

    For example, for WhatsApp:

    adb shell am set-inactive com.whatsapp false

For a permanent effect, add the application to the "uninstallable" list:

adb shell pm hide

โš ๏ธ Attention: On Android 13+ these commands may not work due to stricter security policies. In this case, you will need to use Shizuku or alternative methods.

adb shell pm list packages | grep "application_name"

For example, for VK:

adb shell pm list packages | grep "vk"-->

Method 4: Changing LMK parameters (requires root)

For experienced users with root access it is possible to configure Low Memory Killer manually. This allows you to increase the threshold of free memory at which the system begins to kill processes. Steps:

  1. Install a file manager with support root (for example, Root Explorer).
  2. Open the file /sys/module/lowmemorykiller/parameters/minfree.
  3. Change the values (example for 4 GB RAM):
    18432,23040,27648,32256,36864,41472

    The higher the numbers, the less often the LMK will trigger.

Alternatively, you can use the application Kernel Adiutor (requires root):

  • ๐Ÿ“ฑ Go to section Memory.
  • ๐Ÿ”ง Find the option LowMemoryKiller.
  • โœ๏ธ Edit the values minfree according to the table:
RAM volume Recommended values minfree
2 GB 8192,10240,12288,14336,16384,18432
4 GB 18432,23040,27648,32256,36864,41472
6+ GB 36864,46080,55296,64512,73728,82944

โš ๏ธ Attention: Incorrect values minfree can lead to system freezes or excessive battery consumption. Before making changes, make a backup copy of the original settings.

๐Ÿ’ก

Changing LMK settings is the most effective method for rooted devices, but requires caution. Start with minimal changes and test stability.

Method 5: Using applications to block uploading

If manual methods seem complicated, you can use specialized utilities. They work on two principles:

  1. Activity emulation โ€”the application periodically โ€œwakes upโ€ the target process, simulating its use.
  2. LMK blocking โ€”intercepts system signals about low memory (requires root).

Popular tools:

  • ๐Ÿ›ก๏ธ Greenify (for hibernating unnecessary processes, freeing up memory for important ones).
  • ๐Ÿ”’ Keep Alive (prevents unloading of selected applications).
  • ๐Ÿ”„ Servicely (restarts background services after unloading).

Configuration example Keep Alive:

  1. Give the application rights Accessibility and Overlay on top of other windows.
  2. Add the desired applications to the protection list.
  3. Activate option Prevent app kill.

โš ๏ธ Attention: Applications like Keep Alive can increase. battery consumption by 10-15%, as they constantly keep processes active. Disable them if you notice the device overheating.

Method 6: Setting process limits (for older versions of Android)

On Android 7.0 and below there was a hidden parameter that limits the number of background processes. It can be changed through ADB or the application Developer Options:

  1. Turn on Developer Mode (as in Method 3).
  2. Go to Settings โ†’ System โ†’ For developers.
  3. Find the option Process Limit or Limit background processes.
  4. Select Without restrictions or the maximum value (for example, 4 processes).

For Android 8.0+ this parameter is hidden, but it can be changed through ADB:

adb shell settings put global bg_process_limit 10
(where 10 is the maximum number of background processes)

โš ๏ธ Attention: On new versions Android (12+) this method does not work due to changes in the memory management mechanism. Manufacturers (for example, Google v Pixel) have completely removed this option.

Alternative for new Android

On devices with Android 11+ you can try using Shizuku + AppOps to manually manage application rights. This will allow you to bypass some restrictions, but does not guarantee 100% results.

Method 7: Modifying the firmware (for advanced users)

If none of the methods helped, a radical solution remains - modifying the system files. This is suitable for users with root and experience with custom firmware. Options:

  • ๐Ÿ“ฑ Installing a custom kernel (for example, FrancoKernel or ElementalX) with custom LMK.
  • ๐Ÿ”ง Editing build.prop โ€” adding lines:
    ro.config.low_ram=false
    

    debug.override_lmk_thresholds=1

  • ๐Ÿ› ๏ธ Using Magiskmodules like LMK Tweaks for fine tuning.

Example of installing a module via Magisk:

  1. Download the module LMK Tweaks from the repository Magisk.
  2. Install it through the app Magisk Manager.
  3. Reboot the device.
  4. Configure the parameters in the file /sdcard/lmk_parameters.conf.

โš ๏ธ Attention: Incorrect modification system files can lead to "briku" device (inability to boot). Always make a backup copy through TWRP before making changes.

๐Ÿ’ก

Modifying the firmware gives maximum control over memory management, but requires deep technical knowledge and risks system stability.

FAQ: Frequently asked questions about unloading applications

Why does the application unload even after all the settings?

On some devices (for example Xiaomi, Huawei) manufacturers block standard methods through deep integration of their algorithms. Try:

  • Disable "Auto-optimization" in the security settings.
  • Add the application to the "White List" (if there is such an option).
  • Use ADBcommands to forcefully disable optimization:
    adb shell dumpsys deviceidle whitelist +
How to check if an application is unloaded from memory?

Use ADB-command to monitor processes:

adb shell dumpsys meminfo | grep "package_name"

Or install the application Process Monitor from Google Play. It shows the status of processes in real time.

Is it safe to use root for these purposes?

Using root always involves risks:

  • ๐Ÿ”ด Loss of warranty (if the device is under warranty).
  • ๐Ÿ”ด Vulnerability to malware (applications gain access to system files).
  • ๐Ÿ”ด Possibility of a "brick" due to incorrect changes.

If you are a beginner, start with methods without root (for example, Method 1 or Method 5).

Why is it more difficult to prevent uploading on new Androids (12+)?

Starting with Android 12, Google tightened the policy background processes:

  • ๐Ÿ”น Limited number background services (maximum 10 per hour).
  • ๐Ÿ”น Introduced CPU usage quotas for background tasks.
  • ๐Ÿ”น Blocking ADB-commands for changing system parameters without root.

Manufacturers (for example, Samsung v One UI 4+) also add their own restrictions. In such cases, only a combination of methods or custom firmware will help.

Which method is the most reliable for devices without root?

For most users, the optimal combination:

  1. Disable battery optimization (Method 1).
  2. Use Keep Alive or Servicely (Method 5).
  3. Configure exceptions in proprietary utilities (for example, Autorun in MIUI).

This gives ~80% success without risks to the system.