I am using picasso library for loading multiple images on grid from server. I have three fragments on main activity.Each fragment loads multiple images on grid from server using picasso. when i navigate from fragment to fragment continously ,the fragments loads slow and then after half hour app get crash due to out of memory error in picasso. How to resolve it?
public class MyAlbImageAdapter extends BaseAdapter {
public List<MyAlbum> _albumList=AppController.getInstance().getPrefManger().getMyAlbums();
public static int flag=0;
private LayoutInflater inflater;
private DisplayImageOptions options;
ImageLoaderConfiguration config;
ImageLoader imageLoader;
Context c;
public MyAlbImageAdapter(Context context,List<MyAlbum> album)
{
_albumList=album;
inflater = LayoutInflater.from(context);
this.c=context;
}
@Override
public int getCount() {
return _albumList.size();
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
// Create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
final ViewHolder holder;
if(v == null)
{
v = inflater.inflate(R.layout.myalb_outer_griditem, parent, false);
holder = new ViewHolder();
holder.imageView = (ImageView) v.findViewById(R.id.thumbnail);
holder.t1 = (TextView) v.findViewById(R.id.alb_name);
holder.t2 = (TextView) v.findViewById(R.id.usr_name);
v.setTag(holder);
}
else
{
holder = (ViewHolder) v.getTag();
}
MyAlbum p = _albumList.get(position);
holder.t1.setText(p.getName());
Picasso.with(c).load(AppConst.BASE_IMAGE_URL+p.getCover()).fit().centerCrop().into(holder.imageView);
return v;}}
Please help, i tried many links on net but didn't find anything useful.
error is:
07-10 12:40:46.230: E/dalvikvm(17680): Out of memory: Heap Size=131107KB, Allocated=129839KB, Limit=65536KB
07-10 12:40:46.240: E/dalvikvm(17680): Extra info: Footprint=131043KB, Allowed Footprint=131107KB, Trimmed=1452KB
07-10 12:40:46.240: E/Bitmap_JNI(17680): Create Bitmap Failed.
07-10 12:40:46.240: E/Bitmap_JNI(17680): Failed to create SkBitmap!
07-10 12:40:48.012: E/dalvikvm-heap(17680): Out of memory on a 198896-byte allocation.