android - JazzyViewPager + ImageLoading = OutOfMemory -



android - JazzyViewPager + ImageLoading = OutOfMemory -

i'm getting outofmemory error when scroll through 70 or images using jazzyviewpager.

there seems bad memory leak somewhere in jazzy pager. see it's holding on images when scroll way past them. on beefier devices i'm getting out of memory after scrolling through 70 images or so.

i'm using universal-image-loader view pager, not sure if has it.

anyone else having issue?

there indeed leak in jazzyviewpager.

i ran memory profiler , found jazzyviewpager maintains map of added views:

private hashmap<integer, object> mobjs = new linkedhashmap<integer, object>(); public void setobjectforposition(object obj, int position) { mobjs.put(integer.valueof(position), obj); }

it adds objects, never removes.

to prepare this, added remove method jazzyviewpager:

public void removeobject(int position) { object removed = mobjs.remove(position); if (removed != null) { logutils.logd(tag, "removed obj @ pos " + position); } }

and called adapter's destroyitem():

@override public void destroyitem(viewgroup container, int position, object obj) { container.removeview(((jazzyviewpager)container).findviewfromobject(position)); // create sure remove reference jazzyviewpager map ((jazzyviewpager)container).removeobject(position); }

i monitored memory usage , everything's fine now.

android android-viewpager out-of-memory universal-image-loader

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -