android universal image loader out of memory -
i'm loading 50 images. in activity have configuration
displayimageoptions defaultoptions = new displayimageoptions.builder() .cacheondisk(true).cacheinmemory(true) .imagescaletype(imagescaletype.exactly) .resetviewbeforeloading(true) .displayer(new fadeinbitmapdisplayer(300)) .build(); imageloaderconfiguration config = new imageloaderconfiguration.builder(getapplicationcontext()) .defaultdisplayimageoptions(defaultoptions) .memorycache(new weakmemorycache()) .diskcachesize(100 * 1024 * 1024) .build(); imageloader.getinstance().init(config);
in binderdata
imageloader imageloader = imageloader.getinstance(); imageloader.displayimage(uri, holder.iv_img);
some images loaded, not , outofmemory
error.
check tips useful info
if got outofmemoryerror in app using universal image loader then:
- disable caching in memory. if oom still occurs seems app has memory leak. use memoryanalyzer detect it. otherwise try following steps (all of them or several):
- reduce thread pool size in configuration (.threadpoolsize(...)). 1 - 5 recommended.
- use .bitmapconfig(bitmap.config.rgb_565) in display options. bitmaps in rgb_565 consume 2 times less memory in argb_8888.
use .imagescaletype(imagescaletype.exactly)(your use tips)- use .diskcacheextraoptions(480, 320, null) in configuration
hope helps!!
Comments
Post a Comment