[Android Software/Hacking General [Developers Only]] NikolaiT:
CREDIT: http://is.gd/7JpR2c

I see this come up over and over again. People saying that a task is running in the background and they think it is killing their battery or hogging all of their memory. So their natural reaction is to download a program made to kill tasks. Here’s the thing… you are likely doing more harm than good by killing tasks that aren’t ready to end. I was the same way when I first got my CDMA Hero. There were tons of things running that I didn’t want so I just kept killing them. After a few weeks I realized that if I stopped using a task killer (and totally uninstalled it in fact) my phone actually began to run better! The applications would close themselves and things just seemed to be running better. I get that there may be short term benefits from clearing a task, but you should still take the time to read through this.

Here is some information directly from Android’s developer page. I have put the important parts in bold. This is quite a lengthy read but honestly I think it’s important.

The following diagram illustrates these loops and the paths an activity may take between states. The colored ovals are major states the activity can be in. The square rectangles represent the callback methods you can implement to perform operations when the activity transitions between states

So… the TL;DNR Version:

Android is hard coded to automatically kill a task when more memory is needed.

Android is hard coded to automatically kill a task when it’s done doing what it needs to do.

Android is hard coded to automatically kill a task when you haven’t returned to it in a long time.

Most services (while possibly running in the background) use very little memory when not actively doing something.

A content provider is only doing something when there is a notification for it to give. Otherwise it uses very little memory.

Killing a process when it isn’t ready only causes it to have to reload itself and start from scratch when it’s needed again.

Because a task is likely running in the background for a reason, killing it will only cause it to re-spawn as soon as the activity that was using it looks for it again. And it will just have to start over again.

Killing certain processes can have undesirable side effects. Not receiving text messages, alarms not going off, and force closes just to name a few.

The only true way to prevent something from running at all on your phone would be to uninstall the .apk.

Most applications will exit themselves if you get out of it by hitting “back” until it closes rather than hitting the “home” button. But even with hitting home, Android will eventually kill it once it’s been in the background for a while.

Questions? Concerns? Feel that I’m wrong? Comment below and let’s discuss!

Addendum:

One thing that I forgot to even address here is that memory works a bit differently in linux than it does in Windows. In general the way memory works is you really only need as much as you plan on using. So if your combined running programs use 100mb of memory, 150mb is more than enough. There is no need to clear what’s running in memory before you hit that 150mb cap. Now in Windows it seems that the system performs a bit better when you have less stuff in memory, even if it’s not full. No doubt those who have been on computers for a while will remember there used to be programs that could clear your memory in Windows also.

Linux however isn’t generally affected by this. While I admit that I don’t know the architecture and reason for this… linux will run the same regardless of if you have 20mb free memory or 200mb. And as I outlined above, Android will automatically start to kill applications if you do get low on memory! Stealing a quote from Chris Johnston, “Buffers and cache in RAM being cleared is silly. Imagine a professor, who rather than writing all the way across the chalkboard, finishes a sentence and immediately erases and starts writing in the upper left corner AGAIN and AGAIN and AGAIN OR imagine you like a song. You record it to the beginning of a cassette tape. When you want a new song, do you re-record over the first song or record after it?”

I have also seen people incorrectly assume that the more memory in use, the faster their battery will die. This would actually be more attributed to the amount of processor cycles (CPU %) going on and not the amount of memory being taken up by a certain program. However, that does lead to a good point! When can a task manager be a good thing? To help you determine what IS slowing down your phone; what may actually be draining your battery faster. While an item using up memory isn’t going to hurt things, an item chewing through your CPU absolutely will. Now I still don’t suggest using a task killer to kill a program that is using up your processor (unless of course it is a zombie process that is going crazy, but you should probably just reboot in that case). But it can help you see what’s going on with your phone. A Task Killer will not ever help you're battery life unless it is killing a poorly-coded app that is always running and eating CPU Cycles, and in that case, you should uninstall that app!

I hope this has helped someone. With all of that said… I always encourage experimenting. It is your phone, and you can do with it what you please. If you swear that a task killer makes your phone amazing, then by all means use it, but know that you're lying to yourself! :D

Thanks for reading.