Question

I'm little bit dissapointed when i will start to test my app on galaxy S3 in API 23. I get an out of memory error when i start my splash screen ! Whoo.

02-01 20:17:29.110: E/AndroidRuntime(6304): FATAL EXCEPTION: main
02-01 20:17:29.110: E/AndroidRuntime(6304): java.lang.OutOfMemoryError
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.content.res.Resources.loadDrawable(Resources.java:2988)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.content.res.Resources.getDrawable(Resources.java:1558)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3573)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3616)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:357)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.milesbox.sport.tracker.LoginActivity.onCreate(LoginActivity.java:11)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.Activity.performCreate(Activity.java:5372)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.access$700(ActivityThread.java:159)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.os.Looper.loop(Looper.java:176)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at android.app.ActivityThread.main(ActivityThread.java:5419)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at java.lang.reflect.Method.invokeNative(Native Method)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at java.lang.reflect.Method.invoke(Method.java:525)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
02-01 20:17:29.110: E/AndroidRuntime(6304):     at dalvik.system.NativeStart.main(Native Method)

My app work well under API 10 to API 18. In the Splashscreen activity i have 4 icons and background image (1900*1200px ~ 400kb). Have you an idea to run my app with no problem of out of memory ?

Was it helpful?

Solution

To really figure it out, you will need to work on an API that the rest of us can see also! However, it's possible that API 23 modifies data structures or objects that your app accesses that have grown in size. Without code and a proper test environment for the rest of us, you might not get much besides this little tip right here:

Out of Memory Error while loading bitmaps

You can always request the expanded heap, but given your situation that's not a true fix, it only masks the real problem.

FYI - if your background is 1900px * 1200px then it's memory alloc is probably taking up 4 * 1900 * 1200 = 9MB (depending on the type of image, but typically its 4 bytes (32-bits) per pixel). It's pretty large, really.

For a good overall link on "OutOfMemory" - this is prob the best on SO:

Strange out of memory issue while loading an image to a Bitmap object

and a good link on heap sizes based on device / API:

Is there a minimal heap size for Android versions?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top