How to detect memory stress, memory reclaim aggressiveness, or OOM kill level in android? -


i'm writing application ~1gb memory footprint. app works fine on devices 4gb memory on devices less 3gb of memory trigger aggressive memory reclaim , trigger oom killer , degrade user experience on system level, (e.g. takes long time go previous app, music player in background gets killed.)

i'm wondering if it's possible query system memory status , adjust memory usage of app accordingly, e.g. use memory conservatively before system kill processes of activitymanager.runningappprocessinfo.importance_service level.

is possible?

first, may want profile app see need memory allocated:

then have ontrimmemory() callback (api 14+), can use free resources when devices short of them:

called when operating system has determined time process trim unneeded memory process. happen example when goes in background , there not enough memory keep many background processes running desired.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -