I am developing a simple Android application which displays a list of users by obtaining their details along with a profile picture from a server. The application consumes a huge amount of RAM(about 180MB). When I analyzed the memory consumption, most of the memory was consumed to display the bitmaps using Picasso. I use a recycler view to display the list of users. Below is the code fragment I use to set the profile images.
public static void setImageURL(Context ctx, String url, ImageView imageView) {
Picasso.with(ctx).invalidate(url);
Picasso.with(ctx).load(url).networkPolicy(NetworkPolicy.NO_CACHE).memoryPolicy(MemoryPolicy.NO_CACHE).into(imageView);
}
Please give me some suggestions to minimize this memory consumption. Thanks in advance.
The problem was with loading images using Picasso without fitting them. Simply adding fit() after load() resolved the issue.
Picasso.with(ctx).load(url).fit().networkPolicy(NetworkPolicy.NO_CACHE).memoryPolicy(MemoryPolicy.NO_CACHE).into(imageView);