flavioarfaria/KenBurnsView

OutOfMemoryError

sanjay-tinyowl opened this issue · 4 comments

Hi,

We are getting OutOfMemoryError very frequently while loading bitmap from KenBurnsView library. Here is the complete error logcat:

java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
at android.content.res.Resources.loadDrawable(Resources.java:3054)
at android.content.res.Resources.getDrawable(Resources.java:1613)
at android.widget.ImageView.resolveUri(ImageView.java:648)
at android.widget.ImageView.setImageResource(ImageView.java:377)
at com.flaviofaria.kenburnsview.KenBurnsView.setImageResource(KenBurnsView.java:125)

Can you tell me the root cause? It seems that bitmap is not getting recycled as soon as the Activity killed by OS. Somehow bitmap remains in memory.

Thanks,
Sanjay

The images resolution is too large. I suggest you to <2000 pixel

Are you having this problem with the standard ImageView?
Em 23/06/2015 07:55, "Pagorn Phetchara" notifications@github.com escreveu:

The images resolution is too large. I suggest you to <2000 pixel


Reply to this email directly or view it on GitHub
#27 (comment)
.

Yeah, on standard ImageView too app crashes. This is the solution I found. All images were kept in drawable folder. So framework was applying its own scaling logic based on the device's resolution. Somehow the image wasn't recycled or the image size gets increased by auto-scaling logic applied by framework. When I moved all my images from drawable to drawable-nodpi, app never crashed.

Do you guys suggest any other solutions?

Thanks,
Sanjay

Your images are too large. I suggest you to use a library that handles image resizing for you in order to solve this issue. There are plenty out there, like Square's Picasso, Bump's Glide, Facebook's Fresco, Tarasevich's Universal Image Loader and Dutta's Ion. What you're having is framework specific, this is not a KenBurnsView bug.