Skip to content Skip to sidebar Skip to footer

Bitmap Memory Leaks

So, before honeycomb, the Bitmap obeject was just a pointer for a native heap memory space( using malloc ), and i could clean that native memory calling .recycle() ; after honeyc

Solution 1:

In any android version whether it is froyo,gingerbread or honeycomb. You have to check yourself for memory management. Yes, from 2.2+ you can adjust you application from sdcard, but keeping the bitmaps in heap memory, always will create problem for whether you use either version. If you want pure using of bitmaps, then why dont you follow their way, try this link. They have given you many ways to managing the bitmaps efficiently. Follow this link: Displaying bitmaps efficiently

Solution 2:

first, any android platform version like: android 2.2, or android 3.0 , or higher than android 3.0, the bitmap that you dont want use, you also need invoke bitmap.recycle()

although android >=3.0 , the bitmap save in the dalvik heap, not save in native heap. so as the java heap, if you have some references to refer the object, the object cann't be gc by system, and the bitmap memory can taken many memory, if you dont ensure the object references counter is zero, it will a big problem.

the Bitmap cache you said can save bitmap, so if you use WeakReference or SoftReference to save the bitmap, and using WeakReference.get() or SoftReference.get() to return the bitmap, the bitmap reference is in right control of system. Otherwise you need manage by yourself.

Solution 3:

As you notice on developer pages they said that weak referencies are outdated solution.. Check all bitmap referenced tutorials from link I left here and try to use scaling down (when possible), caching and AsyncTask, as well as lazy bitmap loading from this example..

These things combined will be solution I am pretty sure..

btw.. I am currently on this topics too, cause just weak references are ok, but not perfect solution and I want to make my app lag-proof for future versions of AndroidOS..

Hope it's not too much links but when we get it, it will work like a charm ;)

Cheers

Post a Comment for "Bitmap Memory Leaks"