Skip to content Skip to sidebar Skip to footer

Java.lang.outofmemoryerror Occur On The Animation Loading?

What I get from the Developer site is 'If in the loading time total size of the animation exceed the value of Virtual heap memory , this error will occur' and For the Solution use

Solution 1:

you can solve your error by 1) increasing your dalvik heap size by android:largeheap="true" in manifest file

2) if your reusing your decoded images then you need to implement Lrucache

3) whenever you decode any image by using decodeSampleBitmapFromResource() then it refences are stored in native heap.it can be cleared by System.gc() to reclaim memory,but we cant depend on this because it is decided by OS when to release it.

4) If u want to clear the native heap you should write a code in NDK

Solution 2:

Have you checked the value of inSampleSize?

options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

You can save bitmap reference, and recycle bitmap in onPause. You just set one image, how can you see the animation? Refer to AnimationDrawable. this animation consists of multi frames.

Post a Comment for "Java.lang.outofmemoryerror Occur On The Animation Loading?"