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.

  1. Auto memory manager is a great app major increase in speed of my HTC Hero just one little problem i had was that when using it my alarm clock didn’t go off :-( not good when you use it for work if you know a work round please let me know

    • Is your Hero rooted or not. If it’s not rooted then you need to add the Clock or Alarm app to the whitelist. (I’m not sure what it’s called on the Hero). If your phone is rooted and you are not using the Auto Clean Up mode then you will need to have a look at your settings and memory usage. I’ve been asked this question tens of times so I’ll write a post about how to deal with this with the details. So check back at the end of the day.

  2. My phone is not rooted and com.android.alarmclock is already in the whitelist still the alarm won’t go off

    • com.android.alarmclock may not be what your alarm program is called. Try starting up the program and then immediately going into AMM and add it to the whitelist.

    • Dave
    • October 28th, 2010

    Is there any hope of getting the OOM priorities to stick? I run a rooted droid 1 and have issues running slacker radio in the background behind google navigation while driving in the car. As your post states the OOM priority always goes back to 2 along with all my other secondary server apps. For whatever reason, the slacker app is always killed first. Any advice on getting this to work?

    • Can you tell me what setting you are using? I would suggest that you use the Mild setting. Also, are you using Froyo? and do you have lots of widgets and services running? If you ONLY had slacker and navigation running I don’t think you would be running out of memory. So there may be something else that’s taking more memory than expected.

      Unfortunately the OOM priority sticking is not something within my technical skills. It requires modding the kernel. So if even if I did it you would have to flash a new kernel as well. I’m not quite ready to be blamed for bricking phones when the kernel doesn’t work so well.

  1. No trackbacks yet.