AMM Beta 2

Hi guys.  Just a quick post to let y’all know that there’s a new beta out.  Check out the changelog for details.  If you have any issues/questions/suggestions just post them in the forum and you should get a response in a reasonable amount of time.

Why apps get killed

A lot of people write me or leave comments in the Market saying that AMM has killed their apps.  Most common is the Alarm apps.  Surprisingly up until now I haven’t blogged about this.  There are two answers to this depending on whether you have rooted your phone or not.  And they are both pretty simple.

Let’s start with the rooted scenario first.  If you have a rooted phone and you are not using the Auto Clean Up mode then when and how apps are killed to free up memory is related to the settings your apply e.g. Default, Mild, Aggressive or a custom setting.  So if the app in question is being killed then it means you are using too much memory.  Unfortunately some of these apps like the Clock/Alarm app run at a relatively low priority and get killed easily.  So the normal advice applies.  Turn down the settings until you are sure everything is still working as normal and turn it up slowly.  Another thing is also to keep your memory usage in check.  Having lots of services, widgets will use up memory.  If you are using a phone that has 256MB of RAM then you probably won’t need too many of those before you run low on memory.  The reality is that some phones don’t have as much memory and get easily overwhelmed.

If you are not using a rooted phone (or use the Auto Clean Up mode) then the answer is even simpler.  Just add the  Clock/Alarm app (or whatever it is you want to not get killed) to the Whitelist.  To do that just bring up one of the Running Processes list and select an app from the list and select “Add to Whitelist”.  After that the app will be added to the Whitelist and won’t get killed.

So that’s basically it.  In all cases apps get killed when the phone hits the memory thresholds that you set.

What are OOM priorities?

Someone brought it to my attention that OOM Priority wasn’t explained in the Help on AMM.  And it seems I haven’t written about it on this blog either.   So I thought I would just do a quick explanation of my understanding.  I don’t profess to be an expert on the subject so please feel free to correct me if anything I mention isn’t correct.

So to start OOM (out of memory) priority is a priority that the Android kernel sets for each process on the Android system.  So when the system is out of memory processes will get killed in descending order i.e. from low priority to high priority to release memory.  The priorities start at -16 at the highest to to +15 at the lowest.  -17 is a special value that is supposed to exclude the process from the oom-killer.  More on the “suppose” later.

These OOM priorities are split into 6 groups that loosely translate to the 5 levels of importance hierarchy in the Andriod SDK.  The 6 groups and their associated priorities are:

  • Foreground Application: -16 to 0
  • Visible Application: 1
  • Secondary Server: 2
  • Hidden Application: 3 to 7
  • Content Provider: 8 to 14
  • Empty Application: 15

OOM Grouping

In AMM you can look at apps grouped into their OOM priorities by looking at the Running Proceses list in the OOM grouping view.

Now about that “suppose” mentioned earlier.  After I implemented the functionality to change the priority of the app I noticed (and numerous people reported) that the priorities weren’t sticking after they were changed.  This included the keep-alive value i.e. -17 OOM priority.  It seems the Android kernel still manages the priorities even if you change them.  What makes this even more confusing is that different users seem to be getting varying mileage when they change.  For some people the kernel changes the priorities back immediately while for others it seems to stick for a long time.

So with that explanation I would suggest that you change these priorities carefully.  Obviously changing them will have could have real effect for how the phone and app runs.

If you still have question on this topic feel free to contact me via the usual channels i.e. comment, email, google group.  Not comments in the Market.