15

Android usually kills background processes if they do not have a persistent notification. Why do apps like whatsapp and Facebook not get killed?

2
  • 3
    Because they run a service I'd say :) I'm not using WA or FB, so I cannot be sure here: To higher their priority, apps can register a service and have an icon shown in the notification tray, so the OOM killer considers them "more important" and "kills other stuff instead", if possible.
    – Izzy
    Mar 26, 2016 at 11:31
  • 1
    I think having an icon in the tray is irrelevant (my WA doesn't have one anyway). As long as the service runs as at a "service process" or higher priority.
    – jiggunjer
    Sep 8, 2016 at 3:13

1 Answer 1

9

Android usually kills background processes if they do not have a persistent notification.

Well most often this is the case, but Android OutOfMemory Killer (the component within Android responsible for killing processes) uses fairly complex logic and criterion to kill apps and processes which host these apps.

In Android, every application runs in a Linux Process. Each Linux Process has a Virtual Machine (Dalvik Virtual Machine or ART Virtual machine) running inside it. There is a limit on the memory a process can demand and it is different for different devices and also differs for phones and tablets.

When Android is running short on Memory space (may be because so many apps are simultaneously running in a device) OutOfMemory killer comes into picture and start killing processes of Apps which are in background first.

Now, apps such as WhatsApp, Facebook uses something called Service and Push notification mechanisms. Service allows app to run some code run in background and even though if App is Killed by OOM Killer, Service can be restarted again by Android when sufficient memory is available to make it run.

Why do apps like whatsapp and Facebook not get killed?

This is not true as Android can kill apps based on their state (such as foreground or background). It is just that the Apps and their component(such as Service) are being restarted as when they receive Push notifications, so that user can interact with the app.

So, as and when Push notification is received (means WhatsApp message), Android can restart the killed app's component(in this case WhatsApp).

This way Android is hiding the complex details of Memory management and process management from user and making sure that user can interact with an app without any issue.

3
  • Is there a way to prioritize whatsapp over facebook, e.g. using tasker to kill something first to prevent the OOMK killing another app? I hear task managers are bad, but this type of bypassing seems desirable?
    – jiggunjer
    Sep 8, 2016 at 3:18
  • This answer has a nice explanation! Do you have any official sources to link to corroborate the logic?
    – asgs
    Mar 15, 2020 at 9:46
  • 1
    I wrote this answer based on my experience as a android developer - there exist plenty of documentation to explore how OOM Killer work and simple google search should help to get handle of it. I did not added those links in my post to keep it simple and understandable to layman's mind and not developer point of view. Mar 15, 2020 at 15:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .