Last year, I mentioned that I gave up Picasso due to memory problems of Picasso in my article why pictures load I Glide first, and I stopped using Picasso for a long time. At that time, I also conducted tests and analyzed the UniversalImageLoader. Glide, Fresco, etc., compared vision (Glide supports dynamic maps, Fresco is very powerful), memory management, lightweight (Fresco is powerful, but relies on too many methods, there are more than 5000 methods), and finally chose Glide.

I have to admit that It is similar to Picasso in terms of how to use It. It loads images smoothly, has a gradual change effect, and is very good in terms of life cycle management. However, there are some weird problems with using It to load images in a GridView or ListView Adapter. There is also an OutOfMemoryException risk when I jump to another Activity and come back with a memory usage that only goes up (occasionally a little bit). Glide is also excellent in general

If Picasso takes up so much memory, why did I decide to reuse it?

Picasso had less than 1/3 of the number of ways to Glide (849 ways for Version 2.5.2, 2879 ways for Version 3.7.0). Picasso could not load a dynamic graph (it could also be done through a third party). If you can solve the memory problem of Picasso, using Picasso is lighter than Glide, of course you would choose Picasso

How to solve Picasso memory usage problem?

In the previous tests, Picasso was loaded small memory footprint and several other pictures compared loading framework is neck and neck, but in a larger load Picasso was compared with several other frameworks have several times the gap in the loading pictures of more than 2 m or so may be completely unable to display images of mobile phone may be different (different), Is it possible to control memory usage by reducing the size of images

Picasso. With (context).load(url).resize(screenWidth/2, screenWidth/4*3).centercrop ().into(imageView);Copy the code

Sure enough, with the resize attribute, loading large images was stress-free and memory was very smooth, with the Picasso using a much smaller memory footprint than Glide even when there were a lot of images.

A little feeling

Maybe many people have found that Picasso can deal with the problem of memory occupancy in such an optimized way. It’s a shame that Picasso has been using it for more than a year. He just looked at the surface usage without in-depth research and problem solving. Perhaps this also has some absolutely, Glide still has what potential to wait for us to discover?

Further reading

  • Memory optimization practice for loading images with Picasso (more on Picasso memory optimization, super useful)
  • GalleryFinal (Demo for Picasso and Glide and other image loading framework memory optimization)