Memory metrics in android apps

I wrote Android application and it have some strange problems with Out Of Memory exception, which appears randomly. Yes, I know that problems with OOM exception usually because of images, and I used all what I can to avoid this problem. The only way I could think to find the place where spend the memory is putting the logs with information about memory everywhere. But I really confused about which values ​​do I need.

I used next values:

  • Runtime.getRuntime().maxMemory()
  • Runtime.getRuntime().freeMemory()
  • Runtime.getRuntime().totalMemory()
  • Debug.getNativeHeapAllocatedSize()
  • Debug.getNativeHeapFreeSize()
  • Debug.getNativeHeapSize()
  • And before OOM exception I have next values:

  • maxMemory: 57344K
  • freeMemory: 9581K
  • totalMemory: 22407K
  • NativeHeapAllocatedSize: 34853K
  • NativeHeapFreeSize: 302K
  • NativeHeapSize: 40060K
  • lowMemory false
  • In this question Android Bitmap Limit - Preventing java.lang.OutOfMemory I see that used compeering ((reqsize + Debug.getNativeHeapAllocatedSize() + heapPad) >= Runtime.getRuntime().maxMemory()) ant in this blog some strange information:

    Debug.getNativeHeapFreeSize(); The free size is the amount of memory from the heap that is not being used, because of fragmentation or provision.

    Also I can not understand haw can be OOM exception if (totalMemory: 22407K) much less than (maxMemory: 57344K).

    Please help me understand how use this values.

    链接地址: http://www.djcxy.com/p/93060.html

    上一篇: Android和运行OOM并剩下可用堆空间

    下一篇: 内存指标在android应用程序