I am working with Android Picasso
Library and after setting image from drawable
folder in placeholder
,I am getting outOfMemory exception. Do picasso
place holder image stays in memory, If yes then how to remove placeHolder
image when actual image is loaded?
Asked
Active
Viewed 262 times
-2

Milad Yarmohammadi
- 1,253
- 2
- 22
- 37

Sana
- 49
- 5
-
1try [this](http://stackoverflow.com/a/31993581/1157879) – Nikhil Aug 29 '16 at 07:35
-
Are you using samsung ? if yes, create you drawable placeholder for each density( hdpi, xhdpi etc). – wojciech_maciejewski Aug 29 '16 at 07:37
-
Obviously this comment is out of subject, but I prefer glide than Picasso. Reasons being https://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en – Sreehari Aug 29 '16 at 07:37
-
Check the Leak Canary. This may help you to ou every leaks on your aplication – Genehme Aug 29 '16 at 07:40
-
Compressing the placeholder image and keeping in different density folder worked for now, thank you for your answers. – Sana Aug 30 '16 at 07:04
2 Answers
1
This happens because system try to Scale it according to density of the device .The solution worked for me is to create a folder named drawable-nodpi
inside your res folder . Then put your placeholder image into that folder .
Let me know if it works .

Mithun Sarker Shuvro
- 3,902
- 6
- 32
- 64
0
You may try resizing your placeholder image since it might be to big and causing OutOfMemory, but it can be also more complex error not only of placeholder. And maybe it's not the problem of placeholder but of current image loaded from url which is too big? You can resize this image with below code:
picasso.with(mContext)
.load(someUrl)
.resize(sizeX, sizeY)
.placeHolder(R.drawable.placeholder)
.into(imageView);

kenzo
- 211
- 1
- 9
-
I am resizing the image which is loaded from url, earlier this error was not show but when I add place holder image after that am getting this error, and does adding resize before placeholder resize placeholder image? – Sana Aug 29 '16 at 10:01
-
This only resize your image from url. For placeholder you should do on your own. In which folder you keep drawable? – kenzo Aug 29 '16 at 11:07
-
Compressing the placeholder image and keeping in different density folder worked for now, thank you for your answer. – Sana Aug 30 '16 at 07:05