Can we rely on our Android app getting a set amount of memory or does it vary between phone models or OS versions?
For example, I have a memory cache, and I\'ve set
It may help you
16 MB is the maximum memory limit given to any given android application. Some second generation phones will return 24 MB of memory for each process or even more.
What is the maximum memory limit given for each process or application in android?
Yes, the maximum heap size varies from device to device. You can check the device's approximate per-application memory class by calling getMemoryClass().
Returns the approximate per-application memory class of the current device. This gives you an idea of how hard a memory limit you should impose on your application to let the overall system work best. The returned value is in megabytes; the baseline Android memory class is 16 (which happens to be the Java heap limit of those devices); some device with more memory may return 24 or even higher numbers.
The only built-in way to change heap size of an app is by setting android:largeHeap="true"
in the AndroidManifest.xml
. This will generally increase heap size from 48 to 128. Keep in mind this approach will only work on 3.x tablets. Otherwise, you'll need a rooted device, which is obviously not something you would want to rely on as a developer.