2

I've constructed a endless scroll listview with large images, comparable to Instagram/Facebook/Tumblr

I use https://github.com/etsy/AndroidStaggeredGrid which is based on AbsListView and https://github.com/nostra13/Android-Universal-Image-Loader for my images. I Use a viewholder pattern for my items.

The problem is that i Keep getting OOM errors (+50 items with 200K images), I tried all settings for Universal Image Loader (UIL) but it only does make very little change. When I take a large (2MB) drawable and populate that one without imageloader everything works perfect, and items get recycled under the hood.

It seems that the combination UIL and Gridview does not work together and the images don't get recycled. I tried with the default imageloader.showImage and also withthe imageloader.loadimage and onLoadingCompleteCallback. Futhermore i tried removing the target imageview from the viewholder but that only results in worse performance.

Quick list of already tried things:

  • disable memorycache of UIL
  • disable diskcache of UIL
  • use .resetViewBeforeLoading(true) of UIL
  • resized images
  • setRecyclerListener --> onMovedToScrapHeap construct for the grid (is not called!)
  • lowering JPG qualty

IMPORTANT: It does work with normal, in app, drawables!

Anyone any clue how to fix/debug this?

The stacktrace:

java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:613)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:589)
at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:78)

EDIT: replaced UIL for Android Volley did fix the problem for me, however it's a workaround.

  • 1
    `I Use a viewholder pattern for my items.` - Hmmm... Are you sure that you're using the ViewHolder pattern correctly? To the extent that views are indeed being recycled? – Jim G. Apr 27 '14 at 14:32
  • Related: http://stackoverflow.com/q/19289812/109941 – Jim G. Apr 27 '14 at 14:38
  • I did look into it quite some time and end up fixing it by using android Volley Lib instead of UIL for the images. Then memory issues where resolved. – user2964904 Apr 28 '14 at 21:31

0 Answers0