Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top