Like most technical people, it didn’t take me long to realise that the amount of free memory on my android phone was starting to run quite low.
And as most technical users from a non-android background, I immediately thought: I need to shutdown (or even kill) some running apps, in order to stop my phone from slowing down.
It turns out that the Android OS is a lot smarter than an average OS, and it deliberately keeps RAM as full as possible.
It all revolves around giving the user the best possible “experience” while using the phone.
Ie the user needs to “feel” like all the apps are running in the background (even if they actually are not), and when a user re-enters an application it should start as quickly as possible, and if appropriate, continue running from where it was last left.
In order to do this Android uses Applications and processes in an interesting way:
- Multiple applications may share processes
- An application may use multiple processes
So, just because a process is “running” it doesn’t mean that the associated application is actually doing anything.
Since there is a limited amount of RAM available for processes, Android needs to get rid of unneeded processes.
It decides which process to get rid of by guessing at which process will least affect the users experience, and then force-kills the process, and immediately reclaims the processes resources (like RAM).
At this point I’m thinking: that’s crazy!
But that’s because I’m used to traditional operating systems, where a process needs to be asked to stop nicely, so it gets a chance to finish anything critical, before closing.
So what does Android do differently?
It saves important state information about the application at the time the user leaves the application… so if that applications processes are killed, the state information has already been saved, ready to be restored when the application/processes are restarted.
Now, given the way Android handles memory and processes, it should always have memory available (by just killing off the appropriate processes), so deliberately shutting down all “unneeded” processes actually isn’t needed, and can actually lead to a situation where Android will actually “seem” slower.
Besides that, some processes are not meant to be killed, so deliberately killing them will just result in them getting re-started anyway.
The only time a task killer would be useful, is if a badly-written, out-of-control application is run on Android… but then, but I’ve yet to see anything like that.