The phenomenon . First, allocate some large blocks of memory on the Java side until we select OutOfMemoryError, and then free them all . Now strange things happen: load even a small image (for example, width: 200, height: 200) by BitmapFactory.decodeXXX (decodeResource, decodeFile, ...) will throw OutOfMemoryError! But its OK to allocate any pure Java large object (for example, a new byte [2 * 1024 * 1024]) now!
Verification I wrote some simple codes to check the problem, which can be downloaded here , click "Alloc" and you will get an OOF error, then click "Free All", now the environment is configured. Now you can click "LoadBitmap" and you will see that it does not work on most Android 2.x phones (but in the emulator it is just normal, odd)
Digging deeper . I'm trying to delve into some dalwick code to find out why and find a possible error in the externalAllocPossible function in HeapSource.c , which is called by dvmTrackExternalAllocation, which prints the message "big byte byte byte bytes for this process" in LogCat.
In externalAllocPossible, he simply wrote:
if (currentHeapSize + hs->externalBytesAllocated + n <= heap->absoluteMaxSize) { return true; } return false;
This means that once, if the native size of the Bitmap allocation plus currentHeapSize ( NOT the actually allocated size , as shown below, in this case it preserves the maximum heap size that we hit but then freed them all) exceeds the limits, the native bitmap distribution is always will fail , but currentHeapSize in Java seems NOT to decrease even when the memory of Java objects has been freed up from 91.3% (set to null and trigger GC)!

Has anyone else encountered this problem?