I am not challenging Android's memory management technique (like killers do). I just want to give an app higher priority even when it's not in foreground or visible (with notification).

AutoKiller Memory Optimizer is able to do it on rooted device, but the change lasts for few seconds if I multi-task.

I want to do this permanently: perhaps running a background daemon to do change continuously should work. How to do this?

  • Same problem here. You can use v6 supercharger for a partial fix to your problems. – Mateen Ulhaq Aug 4 '12 at 20:57
  • You could ask the developer to add an (optional) service with the app. Apps having a service connected are less likely to get killed by OOM. – Izzy Aug 4 '12 at 23:05
  • 1
    @Izzy Priority of apps having services is lower than foreground & visible ones. BTW, how many developers you are suggesting me to calculate? Its not a solution... – user3303 Aug 5 '12 at 19:58
  • @SachinShekhar you are right, but with a running service the prio is still higher than that of other "background apps", as far as I remember. And as far as I understood, you where concerned for one specific app -- so I'd suggest that specific developer :) But OK, it was just a suggestion. Sorry it's no help to you -- was worth a try, though. – Izzy Aug 5 '12 at 20:10
  • Did you check Keeping an app in memory? Looks like that would answer your question. – Izzy Aug 27 '12 at 9:42

On XDA I found a post discussing how to PIN an app to not get killed by OOM. As your question indicates your device is rooted, this could be useful for you. The principle described there can be applied to your case as well by simply changing the oom_adj value specified (the -17 would permanently PIN it, highest prio -- so use a larger value to "weaken" that).

The script snipped posted there looks like this:

sleep 60

PPID=$(pidof com.estrongs.android.safer)
echo "-17" > /proc/$PPID/oom_adj

An anonymous user noted you could also set this file to read-only permissions to prevent Android from updating it, adding chmod 444 /proc/$PPID/oom_adj to the above script (the proposed 444 means nothing but read permission, but doesn't affect the system's ability to remove the file when the process ends). I have not verified that, but this could in fact save you from looping/repeatedly running the script, making the set value permanent for as long as the process lives.

As said, replace the -17 by your chosen value. Also replace the app's package name (com.estrongs.android.safer) by the package name of your target app. You can also lower the sleep value, or even ommit the sleep at all.

Now you need a way to auto-execute this as soon as your app is running. For this part, you could e.g. use Tasker: Context would be "app running" (and your app selected), and the task "run shell", with above script as parameter. Then, as soon as you start your app (and it comes to foreground), Tasker would execute the script -- and the oom_adj value should be applied.

  • i notice that if i background the app, the oom_adj value changes. does this mean that the app has actually been unpinned? – Michael Sep 19 '13 at 22:05

It can't be done from a application's code (background service or thread or whatever). Reason is well described in this post, http://debuggingisfun.blogspot.com/2014/03/android-foolproof-low-memory-killer.html

  • Welcome to Android Enthusiasts! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Matthieu Harlé Mar 16 '14 at 10:52

ROM Toolbox Pro by Jrummy has built-in OOM manager.

  • 1
    That's similar to AutoKiller Memory Optimizer.. Read the question again.. – user3303 Mar 8 '13 at 23:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.