android - java.lang.outofmemoryerror bitmap on a fragment pager -
i have memory leak problem can't find way solve. there many questions in stackoverflow no 1 of them useful me.
i have activitiy view pager , action bar tabs navigation. in every fragment load 1 image sort of gallery in end. works nice.
after fragment changes, got error:
e/androidruntime(19271): java.lang.outofmemoryerror e/androidruntime(19271): @ android.graphics.bitmap.nativecreate(native method)
all i've read need of deallocating images, thought about:
- event @ "fragment lost focus"
- delete views inside fragment focus has lost
but can't find solution that. correct way? if so, can give example? or i'm wrong , solution way?
this how add images fragment:
imageview img = new imageview(rootview.getcontext()); img.setvisibility(1); img.setimageresource(r.drawable.gallery_image_1); img.setadjustviewbounds(true); img.settag( "gallery_image_1" ); gallery.addview(img);
thanks in advance!
diego
first of all, make sure you're using fragmentstatepageradapter, it's more memory-friendly fragmentpageradapter
.
second, analyze application mat find causes memory leaks. here's excellent post describing how tool can used in context of android.
Comments
Post a Comment