模拟器上的Outofmemoryerror,API级别仅为15级Android

时间:2013-02-27 09:34:34

标签: java android memory out-of-memory

尝试使用API​​级别15返回模拟器中的Activity时出现此错误。

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!

最大VM堆大小为48,设备ram大小为512,但奇怪的是,使用具有完全相同的堆大小和内存大小但具有API级别16的不同仿真器,它可以正常工作。它也适用于API级别为8且堆大小为24的模拟器以及API级别为10的真实设备。

API级别15是否有特殊内容,或者我应该忽略它作为模拟器错误?

感谢您的回复。

1 个答案:

答案 0 :(得分:-1)

嗨,可能是问题是在位图大小或其他问题或者堆大小增加请查看这些帖子,这可能对您有所帮助

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

OutOfMemory exception when loading bitmap from external storage