Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From deployments in the wild, I've found the following devices:</p> <ul> <li><strike>Devices that limit to 16 MiB of java heap (bitmaps are nearly unlimited).</strike></li> <li>Devices that limit to 16 MiB of (java heap + native bitmap storage)</li> <li><strike>Devices that limit to 24 MiB of java heap (bitmaps are nearly unlimited).</strike></li> <li>Devices that limit to 24 MiB of (java heap + native bitmap storage)</li> </ul> <p>24 MiB tends to be the high res devices, and can be detected with Runtime.getRuntime().maxMemory(). There's also 32MiB devices now, and some of the rooted phones have 64MiB by default. Previously, I confused my self several times trying to work out what was happening. I think all devices count bitmaps into the heap limit. But it's wildly difficult to make any sweeping generalizations about the android fleet.</p> <p>This is a VERY nasty issue on Android, and very confusing. This limit and it's behaviors are poorly documented, complicated, and extremely non-intuitive. They also vary across devices and OS versions, and have several known bugs. Part of the problem is that the limits are not precise - due to heap fragmentation, you will hit OOM well before the actual limit and must conservatively leave a meg or two of buffer. Even worse, I've got several devices where there is a native segfault (100% a bug in Android itself) that occurs before you get the java OOM exception, making it doubly important to never reach the limit since you can't even catch the native crash. For more details on my investigations, check out <a href="https://stackoverflow.com/questions/6892676/android-bitmap-limit-preventing-java-lang-outofmemory">this post</a>. In the same post, I explain how to measure usage against the limit and avoid crashes.</p> <p>The size of the java heap is Runtime.getRuntime().totalMemory().</p> <p>There is no easy way to measure the size of the native bitmap storage. The overall native heap can be measure with Debug.getNativeHeapAllocatedSize(), but only the bitmaps count toward the limit (i think).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload