I wrote an Android app and it has some weird issues with Out Of Memory exception, which appears randomly. Yes, I know that problems with OOM exceptions are usually due to images, and I used everything I could to avoid this problem. The only way I could find to find a place to spend memory is by putting logs with memory information everywhere. But I'm really confused by what values I need.
I used the following values:
- Runtime.getRuntime (). maxMemory ()
- Runtime.getRuntime (). FreeMemory ()
- Runtime.getRuntime (). totalMemory ()
- Debug.getNativeHeapAllocatedSize ()
- Debug.getNativeHeapFreeSize ()
- Debug.getNativeHeapSize ()
And before the OOM exception, I have the following values:
- maxMemory: 57344K
- freeMemory: 9581K
- totalMemory: 22407K
- NativeHeapAllocatedSize: 34853K
- NativeHeapFreeSize: 302K
- NativeHeapSize: 40060K
- lowMemory false
In this question, Android Bitmap Limit - Prevent java.lang.OutOfMemory I see that the used compeering ((reqsize + Debug.getNativeHeapAllocatedSize () + heapPad)> = Runtime.getRuntime (). MaxMemory ()) ant in this blog is somehow strange information:
Debug.getNativeHeapFreeSize (); Free space is the amount of memory from a heap that is not in use, due to fragmentation or position.
Also I cannot understand that haw can be an OOM exception if (totalMemory: 22407K) is much less (maxMemory: 57344K).
Please help me understand how to use these values.
anber source share