0

Logcat FATAL EXCEPTION: main Process: com.example.markpalmer.blackjack21, PID: 21864 java.lang.OutOfMemoryError: Failed to allocate a 5808012 byte allocation with 5226696 free bytes and 4MB until OOM

Hi, I know there are some posts regarding this, but I don't really understand the answers. The error is random, and occurs when setting an imageview:

ivPlayerCard3.setImageResource(picP3);

The images are not large: 36kb, 500x700 .png files. The thing is for no particular reason I have put them in the res>mipmap-hdpi folder. Could this be the reason for my problem. Would shifting them to the drawable folder help? Many thanks in advance.

1 Answer 1

0

Why don't you try setting thee imageResouce using well known libraries like Picasso check the doc here

Picasso handles OOM very well by loading the image in segments or fractions. Also moving them to drawable might help as mipmap actually creates a map of the image, but a better solution is to use Picasso hope this helps!

Sign up to request clarification or add additional context in comments.

3 Comments

Hi. Where does the Picasso download go in relation to Android Studio please. Sorry, not the best of questions, but I don't know what to do with it
Sorry, I've found a pretty in depth post - I will give it a blast
Hey, no worries, you can add it to your app via the build.gradle (app) file. Look for the dependency{...} object and add this there compile 'com.squareup.picasso:picasso:2.5.2' sync your project and you're good to go!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.