Hey guys! Jerry is back with another neat trick you can do on your Android phone. This one helps keep things running smoothly and gives us some custom control over Android’s internal task killer. Like most things that affect the low-level operation of Android, it requires root, but it’s a good read even for those people who don’t feel the need to root (and violate their warranty!) because you just might have a better understanding about what’s going on behind the scenes. Open a couple of extra tabs in your browser, get your phone (and maybe even a USB cable) ready, and keep an eye out for a break.

Oh, and a warning: this is pretty low-level stuff. It’s not hard to do, but then , what he does, a little advanced. Don’t say we didn’t warn you.

Linux and Android

You hear over and over again that Android runs on the Linux kernel. The biggest advantage of this is that Linux is stable, open source, and extremely hackable. This means that many of these benefits extend to Android as well. The ability to set up a low-memory killer is one of them. This is something I have personal experience with, both difficult and easy. While this is beneficial for all versions of Android, phones with HTC Sense will show the most improvements.

How the memory killer works

When your phone boots up, a file inside the boot image (init.rc) sets the system parameters. Things like navigating to the framework files, configuring your networks, and setting limits at which programs are removed from free RAM are all done by this file. Now the super Android geek can dig into the init.rc file and fully customize the low memory killer, but you don’t have to do that to get good results. Init.rc installs six different «tiers» of open applications. Let’s take a look at them:

  • FOREGROUND_APP : This app is currently on screen and running
  • VISIBLE_APP : this is an application that is open and running in the background because it is doing something else
  • SECONDARY_SERVER : is a process (a service that the application needs) that is alive and ready in case something needs to be done
  • HIDDEN_APP : This is again a process that is idle (but still alive) in case it is needed by an application that is alive and running

For the most part, we never want to adjust when these apps and processes are killed. These are the things that the programs we use need to function properly. For the more daring and experienced users, changing the settings for options HIDDEN_APP possible, albeit with a lot of trial and error. There are two more settings, and they are the most interesting for us today:

  • CONTENT_PROVIDER : These are applications that provide data (content) to the system. HTC Facebook Sync? it CONTENT_PROVIDER . Things like Android Market or Fring. If they are alive, they can update and provide the content they need to do at a given interval. If you kill them, they certainly can’t.
  • EMPTY_APP : I call these «ghosts». These are applications that you have opened but made with them. Android uses a unique style of memory management. When an activity ends, instead of killing it, Android keeps the app in memory so that reopening it is a faster process. These «ghost» apps don’t use batteries or CPU time, they just fill up RAM that would otherwise be empty. When this memory is required by another application or process, the RAM is reset and made available for the new application. To satisfy geeky people (like me), Android does this by keeping a list of recently used apps, with the oldest apps on the list having the lowest priority — they are killed first if RAM is needed elsewhere. This is the perfect way to handle «ghost» processes, so no need to touch that part 😉

At the level EMTY_APP we can play Robin Hood and get some interface performance. We rob the rich (the RAM used by the applications we use) and give to the poor (our pool of free RAM). In this way, we decide when Android closes old, unused apps rather than letting the system decide for us. That’s why we get sick.

top linux command

I want to emphasize — there is nothing wrong with the way Android handles this out of the box. It’s efficient, works well every time, and stays stable. It is our intervention and the need for immediate gratification that is the real problem. Waiting .3 seconds never killed anyone again. But I’m just as guilty as anyone else and I want immediate results, so let’s do it!

How do we manage all this?

Remember earlier I said that you don’t have to dig into the cryptic startup files to change these settings? Well, you’ll love it. You can change things with an app from the Market! There are a few that work but I prefer MinFreeManager, because it’s lightweight and doesn’t share personal information like some others. Let’s see how to set up this bad boy.

Step one — remove any task manager that works for you. They will only interfere with what we are doing today. If you don’t, we’ll all show and laugh while our phones work fine 🙂

step two — download and install MinFreeManager

Manager's QR code

[ Рынок Ссылка | AppBrain ]

Step Three — open the application. Hit the back button to get rid of the keyboard (we’ll talk about editing numbers, which you’ll see in a bit), and hit menu > presets.

MinFreeManager Menu

Select Aggressive. There is no point in installing and running such an application without running it in full force. If after a day or two you think you’re having trouble starting at these settings, you can try «moderate» or tweak the numbers manually. Then click «Apply» to set the options. If you want the settings to apply on every reboot, the >> apply menu on boot takes care of you. For most, that’s it. Enjoy having 75-100MB of free RAM all the time.