Verdict: When an Android phone terminates your music player, drops a continuous VPN tunnel, or delays push notifications from messaging apps, the culprit is almost never insufficient physical RAM. Instead, it is driven by aggressive proprietary OEM battery-saver daemons (such as Samsung’s Device Care “Deep Sleep”, Xiaomi’s MIUI/HyperOS Memory Cleaner, and OnePlus’s Quick Launch freeze) overriding the standard Linux Low Memory Killer Daemon (LMKD) and Android’s Phantom Process Killer (which enforces a strict limit of 32 child processes per UID). You can prevent apps from being terminated by locking them in the Recent Apps carousel, setting App Battery Usage to “Unrestricted”, disabling OEM memory auto-clear schedules, and using ADB to disable the Phantom Process Killer.
One of the enduring ironies of modern Android flagship hardware is that you can purchase a device with 12GB, 16GB, or even 24GB of physical RAM, only to have the operating system violently kill a pedometer, torrent client, podcast player, or messenger five minutes after locking your screen.
For app developers and power users, aggressive background app killing has long been cataloged as a critical usability barrier. While recalibrating your phone’s battery management system can resolve inaccurate gauge readings, OEM smartphone manufacturers compete aggressively in battery endurance test rankings; to post extra hours of screen-on time in benchmark reviews, they implement proprietary background task killers that disregard Android’s standard background execution guidelines.
Here is an engineering overview of how Android manages application lifecycles, how OEM task killers intervene, and the step-by-step methods to whitelist mission-critical apps permanently.
The Android Background Process Hierarchy
To understand why an app gets terminated, you must first understand how the core Android framework categorizes processes. The operating system assigns every running task an oom_adj_score (Out of Memory Adjustment Score) ranging from -1000 (critical system process) to 1000 (cached, expendable background app). When free memory runs low, the Linux Low Memory Killer Daemon (LMKD) scans the process list and kills higher-scoring tasks first.
| Process Priority Tier | oom_adj_score Range | Typical Examples | LMKD Kill Vulnerability |
|---|---|---|---|
| Foreground Process | 0 | The active app currently visible on screen; interactive UI | Never killed unless extreme kernel out-of-memory crash |
| Visible / Perceptible Process | 100 to 200 | Picture-in-picture video; overlay widgets; accessibility services | Protected; killed only under critical memory pressure |
| Service Process (Foreground Service) | 200 to 400 | Spotify / YouTube Music with notification; active GPS navigation; VPN | Protected in stock Android, but heavily targeted by OEM battery daemons |
| Cached / Background Process | 700 to 900 | Apps minimized when pressing Home; paused games in memory | Standard reclamation target; safely terminated to free buffer cache |
| Empty / Orphaned Process | 900 to 1000 | Defunct app processes retained only to speed up cold re-launch | Terminated immediately when any active task requests memory allocation |
The Real Culprit: Proprietary OEM Battery Daemons
In standard AOSP (Android Open Source Project) running on Google Pixel devices, a process running a legitimate Foreground Service—accompanied by an active persistent notification in the status bar—is virtually immune to termination unless memory reaches catastrophic exhaustion.
However, major smartphone vendors layer custom background-killing services over the Linux kernel:
- Samsung One UI: Employs Device Care (App Power Management). It divides apps into “Sleeping apps” and “Deep sleeping apps”. If an app runs a background service for several consecutive minutes without screen interaction, One UI places it in deep sleep, halting its alarms, wakelocks, and sync jobs completely.
- Xiaomi HyperOS / MIUI: Integrates a proprietary daemon called MIUI Battery Saver. By default, it restricts background activity for every newly installed third-party app after 10 minutes of screen-off time, ignoring standard foreground notification flags.
- OnePlus / OPPO / Realme (ColorOS / OxygenOS): Features aggressive RAM optimization that caps background processes, kills wake locks, and restricts “Auto-Launch” permissions, preventing messaging apps from starting after a device reboot.
What Is the “Phantom Process Killer” in Android?
Introduced in Android 12 and maintained across Android 13, 14, 15, 16, and 17, the Phantom Process Killer is an internal Android framework component designed to stop rogue background apps from spawning heavy CPU-draining sub-processes.
Here is how it works: whenever an app runs, it is allowed to fork child processes (for example, a terminal emulator, a game compiler, or a background torrent client spawning networking threads). The Phantom Process Killer enforces a hard ceiling: maximum 32 child processes across all background apps combined, and caps the cumulative CPU usage of those child processes. If a background app exceeds this threshold, the kernel immediately issues a SIGKILL signal, crashing the background service without notifying the user.
Step-by-Step: How to Stop Android from Killing Your Apps
Step 1: Set App Battery Usage to “Unrestricted”
This is the fundamental operating system toggle that exempts an app from Android’s unified battery optimization framework (Doze mode):
- Go to Settings > Apps > See all apps.
- Select your target application (e.g., your music app, VPN, smart watch companion, or automation utility).
- Tap App battery usage (or Battery).
- Change the selection from Optimized to Unrestricted.
Step 2: Lock the App in the Recent Apps Carousel
Locking an app marks its PID (Process ID) with a persistent keep-alive flag, preventing OEM task killers from wiping it when you tap “Clear All” in the multitasking switcher:
- Swipe up from the bottom of your screen to open the Recent Apps / Multitasking view.
- Locate the card of the application you want to preserve.
- Tap the App icon above the preview card (or long-press the card).
- Tap Lock this app (or Keep open). A small padlock icon will appear on the card.
Step 3: Remove from Samsung “Deep Sleeping Apps” (One UI)
- Open Settings > Battery (or Device care > Battery).
- Tap Background usage limits.
- Ensure Put unused apps to sleep is either disabled or check both Sleeping apps and Deep sleeping apps lists.
- If your app appears in either list, tap the trash/remove icon and delete it.
- Tap Never auto-sleeping apps, tap the + icon, and add your mission-critical app to this permanent exclusion whitelist.
Step 4: Disable MIUI / HyperOS Battery Saver (Xiaomi, Poco, Redmi)
- Open Settings > Apps > Manage apps.
- Select your app > enable Autostart (allow background autostart).
- Scroll down to Battery saver and change the setting from MIUI Battery Saver (recommended) to No restrictions.
- Under Settings > Battery > Gear icon, verify that Clear cache when device is locked is set to Never.
Step 5: Disable the Phantom Process Killer via ADB (Power Users)
If you run advanced local utilities (such as Termux, local Python servers, Syncthing, or heavy torrent downloaders), Android’s 32-process limit will still kill your tasks regardless of UI battery settings. You can permanently disable the Phantom Process Killer using Android Debug Bridge (ADB):
- Enable Developer options and toggle on USB debugging on your smartphone.
- Connect your phone to a PC/Mac with ADB installed.
- Open your terminal and run the following command to verify connection:
adb devices - Execute the following command to disable the Phantom Process Killer:
adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647" - To prevent DeviceConfig from resetting this value on reboot in Android 13/14/15/16/17, run:
adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent"
Summary Checklist: Keeping Apps Alive
To guarantee that a background service never gets terminated unexpectedly, follow this three-layer rule:
- Layer 1 (OS Permission): Set Battery Usage to Unrestricted in App Info.
- Layer 2 (OEM Daemon): Add to Never Auto-Sleeping (Samsung) or enable Autostart + No Restrictions (Xiaomi/OnePlus).
- Layer 3 (Multitasking Engine): Keep the app locked in the Recent Apps switcher with the padlock icon.
Applying these adjustments ensures continuous background audio playback, immediate message receipt, reliable fitness syncing, and uninterrupted VPN protection.

