Search code examples
javaandroidcachingmemorypicasso

Picasso MemoryPolicy.NO_CACHE/NO_STORE still increasing allocated and memory consumption


So, I got into an issue with memory

java.lang.OutOfMemoryError

I find out it was due to Picasso Library which is caching images and creating error java.lang.OutOfMemoryError so I find the solution for it and added android:largeHeap="true" to my manifest and no error faced after that but does that solved my problem NO!
So I have few large images and few Small images so started to skip caching Large images in my app
by using MemoryPolicy like this:-

 Picasso.with(this).load('''').memoryPolicy(MemoryPolicy.NO_CACHE,MemoryPolicy.NO_STORE).error(R.drawable.noimagefound).placeholder( R.drawable.progress_animation ).fit().into(backdrop);

yet I saw incsearing memory consumption by my app:- enter image description here

which makes my app laggy after sometimes

there is significant increase as i load large images Is there any proper standard to use cache or after a certain time clearing it and am i using it properly and then also increasing allocated size?
any hint will be helpful
thanks!


Solution

  • Picasso cannot do anything if your bitmaps are really large. You need to resize the image before loading them. Add .resize(width, height) in the picasso chain to load smaller bitmaps.