outOfMemoryError with background drawables

前端 未结 1 978
悲哀的现实
悲哀的现实 2021-01-07 04:54

I read a lot about memory leaks with Bitmaps but I can\'t solve my problem. I have an app works fine in my phone, but in others I\'m getting the outOfMemoryError bitmap size

1条回答
  •  迷失自我
    2021-01-07 05:07

    Recycle bitmaps when not in use. After honeycomb bitmaps stay on heap.

       bitmaps.recycle();
    

    http://android-developers.blogspot.de/2009/01/avoiding-memory-leaks.html. The link above has a topic on how to avoid memory leaks.

    Also if you have high resolution image , you should scale down. See the topic under Load a Scaled Down Version into Memory.

    http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

    Suppose you navigate form actiivty A to B. In onPause() recycle bitmaps. In onResume() load bitmaps. Do this for every activity where you load bitmaps.

    Since you use MAT, you should look at the link below to find and solve memory leaks http://www.youtube.com/watch?v=_CruQY55HOk

    0 讨论(0)
提交回复
热议问题