Outofmemoryerror on emulator with API level 15 only Android

Question!

I'm getting this error when trying to go go back to an Activity in my emulator with API lvl 15.

    02-27 09:20:54.282: E/dalvikvm-heap(629): Out of memory on a 17040400-byte allocation.
02-27 09:20:54.343: E/AndroidRuntime(629): FATAL EXCEPTION: main
02-27 09:20:54.343: E/AndroidRuntime(629): java.lang.OutOfMemoryError
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:374)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:404)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.visma.sandbox.rotatingmenu.v.BitmapResourceSet.loadBitmap(BitmapResourceSet.java:92)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.visma.sandbox.rotatingmenu.v.BitmapResourceSet.loadAndCacheBitmap(BitmapResourceSet.java:84)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.visma.sandbox.rotatingmenu.v.BitmapResourceSet.load(BitmapResourceSet.java:49)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.visma.sandbox.RotatingMenuSurface.loadBitmapResourceSet(RotatingMenuSurface.java:118)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.visma.sandbox.RotatingMenuSurface.surfaceCreated(RotatingMenuSurface.java:69)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.SurfaceView.updateWindow(SurfaceView.java:533)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:226)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.View.dispatchWindowVisibilityChanged(View.java:5839)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:945)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:945)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:945)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:965)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.os.Looper.loop(Looper.java:137)
02-27 09:20:54.343: E/AndroidRuntime(629):  at android.app.ActivityThread.main(ActivityThread.java:4424)
02-27 09:20:54.343: E/AndroidRuntime(629):  at java.lang.reflect.Method.invokeNative(Native Method)
02-27 09:20:54.343: E/AndroidRuntime(629):  at java.lang.reflect.Method.invoke(Method.java:511)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-27 09:20:54.343: E/AndroidRuntime(629):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-27 09:20:54.343: E/AndroidRuntime(629):  at dalvik.system.NativeStart.main(Native Method)
02-27 09:23:09.022: E/InputDispatcher(90): channel '41643028 com.visma.sandbox/com.visma.sandbox.IncomeInfoMenu (server)' ~ Channel is unrecoverably broken and will be disposed!

Max VM heap size is 48 and device ram size is 512 but thw wierd thing is that with a different emulator with the exact same heap size and memory size but with API Level 16 it works just fine. It also works on emulators with API level 8 with heap size of 24 and my real device with API level 10.

Is there something special with API level 15 or should I ignore this as a emulator bug?

Thanks for resopnse



Answers

Hi may be the issue is in Bitmap size or something or else Heap size is increase please check these posts this may be helpful to you

Out of memory error on android emulator, but not on device

OutOfMemory exception when loading bitmap from external storage



This video can help you solving your question :)
By: admin