0

I have a view pager with four pages, and each page have a listView. Everything's ok so far, but when i scroll the list it kicks thousand times GC_EXTERNAL_ALLOC and it dicreases performans of my app. So i track allocations by DDMS by following Romain Guy's documentation and saw that's because of loading images to list items.

I save images and then check if there is that image as saved before, if there is, i use:

 img.setImageDrawable(Drawable.createFromPath(imagePath));

When i get allocation tracks, it shows me that this line has allocated lots of memory while scrolling... I just wonder why? And if there is any affective way to load images to suggest me?

Any help would be appreciated.

yahya
  • 4,810
  • 3
  • 41
  • 58

2 Answers2

1

I assumed that you need to show some 'N' number of images in a list view and this images are getting from internet.

Refer: Fedors Lazy Loading

Community
  • 1
  • 1
Dinesh
  • 414
  • 1
  • 6
  • 13
  • I guess Fedors LazyList example is easy enough and has affective performans. Thanks. I'll give it a shot. But i still wonder why getting from drawable causes this much memory allocation.. – yahya Jan 03 '13 at 08:18
1

The best document you can find is here : http://developer.android.com/training/displaying-bitmaps/index.html

But it's quite complex to be honest. In next version of RoboSpice, we hope to provide a way to encapsulate all this complexity (ui-spicelist module).

Snicolas
  • 37,840
  • 15
  • 114
  • 173