-1

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 ?

WhatsUp
  • 453
  • 1
  • 5
  • 21
  • From where u received update for api 23..?? :D , what are u doing with 4 image. are u creating bitmap .? – Manmohan Badaya Feb 01 '14 at 19:34
  • 2
    API 23 is FUTURE. We're still at API 19. ;) – Phantômaxx Feb 01 '14 at 19:34
  • 02-01 20:40:34.290: E/(15925): Device driver API match 02-01 20:40:34.290: E/(15925): Device driver API version: 23 02-01 20:40:34.290: E/(15925): User space API version: 23 02-01 20:40:34.290: E/(15925): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST 2013 For 4 images i have 4 png , 3 icons in 114*114 and 1 background Maybe OS bug ? – WhatsUp Feb 01 '14 at 19:43
  • 1
    did you Google > site:stackoverflow.com android outofmemory bitmap? – Ben Pearson Feb 01 '14 at 20:02

1 Answers1

2

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?

Community
  • 1
  • 1
Jim
  • 10,172
  • 1
  • 27
  • 36
  • Thanks, i will retest with omitting all png and it works i think this my background image, what is the right way for sizing a fullscreen image in background for full hd phone ? – WhatsUp Feb 01 '14 at 19:53
  • Lots of approaches for handling OOM - I edited my answer. Take a look :) – Jim Feb 01 '14 at 19:55
  • I find this, this is the sizing recommendation for fullscreen images but it miss xxhdpi : xlarge (xhdpi): 640x960 large (hdpi): 480x800 medium (mdpi): 320x480 small (ldpi): 240x320 – WhatsUp Feb 01 '14 at 20:00
  • If your test environment is setup wrong, you might hit the heap limit prematurely. For real devices, that xxhdpi heap should be at least 128MB. I edited my post to address your question – Jim Feb 01 '14 at 20:14