Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

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?

share|improve this question
    
Same problem here. You can use v6 supercharger for a partial fix to your problems. –  muntoo 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... –  Sachin Shekhar 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

3 Answers 3

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:

#!/system/bin/sh
sleep 60

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

Now, 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.

share|improve this answer
    
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

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

share|improve this answer
1  
That's similar to AutoKiller Memory Optimizer.. Read the question again.. –  Sachin Shekhar Mar 8 '13 at 23:10

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

share|improve this answer
    
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. –  Shywim Mar 16 at 10:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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