Reputation: 11813
I know that Android may kill applications e.g. if it's low on memory. In a comment to another question a user stated that if my app would require less memory, it would be less likely to be killed. I wonder: is this true? Where is such a behavior documented? Which other factors influence the likelihood of being killed?
Upvotes: 2
Views: 318
Reputation: 1006819
is this true?
Perhaps.
Where is such a behavior documented?
It's not, which is why the answer to the previous question is "perhaps". The only way to determine the behavior would be to examine the Android source code, and that would only be relevant for Android devices built using that same source code. Not only can Google change the algorithm over time, but device manufacturers and ROM modders can change the algorithm as well.
Which other factors influence the likelihood of being killed?
The primary determinant is what is in the process, as is described in the documentation. So, a process with a running activity will be less likely to be terminated than a process with no running components at all.
Nothing else is formally documented. My understanding is that process age is a factor, so that apps with a service do not live forever, but I don't recall that this is mentioned in the docs.
Also, bear in mind that the user can get rid of your process whenever the user wants, via the recent-tasks list on 4.0+, or via a third-party task manager, or via Settings. Hence, you should make few assumptions about the longevity of your process.
Upvotes: 4