android - When can I recycle a Bitmap? -


i'm having serious issues memory, , i'm looking forward recycle bitmaps.

however, app doing atm, building gallery (yeah, deprecated) several bitmaps, , then, several galleries.

so @ end of day, app looks (linearlayout style):

*some webviews *a gallery 7 images. *some webviews *a gallery 10 images

and on.

so i'm thinking is... once i've displayed images, , them on screen, can bitmaps recycled?

is there way recycle whole gallery component?

thank much.

edit:

i've tried soo many things. i'm still getting error java.lang.illegalargumentexception: bitmap size exceeds 32bits

this actual code:

bitmapfactory.options bfoptions=new bitmapfactory.options();          bfoptions.indither=false;          //disable dithering mode         bfoptions.inpurgeable=true;       //tell gc whether needs free memory, bitmap can cleared         bfoptions.ininputshareable=true;  //which kind of reference used recover bitmap data after being clear, when used in future         bfoptions.intempstorage=new byte[32 * 1024];          bfoptions.ininputshareable=true;         bfoptions.inpreferredconfig = bitmap.config.rgb_565;                bitmap bitmap = bitmapfactory.decodefile(murls.get(position).getpath(), bfoptions);          inflatedimageview.setimagebitmap(bitmap.createscaledbitmap(bitmap, 120, 120, false)); 

as can see, i've set many options bitmap, aswell resizing it, , lowering it's quality. still happenning same issue.

first should never manually call system.gc, , there no need manually recycle bitmaps either. let operating system best at, deciding when take huge hits run garbage collection.

one of reasons gallery deprecated sure loads items renders. , not load them , recycle them on demand list view. means huge waste of ram , no amount of recycling you. in addition gallery glitchy on 4.0+ phones, majority of android user base @ point. recommend move away using gallery.

there 2 alternatives.

1) view pager built support v4 library

2) horizontallistview --> https://github.com/meetme/android-horizontallistview

also absolutely sure downsampling images prior loading them in image views. learn how read http://developer.android.com/training/displaying-bitmaps/load-bitmap.html


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -