尝试返回到 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 有什么特别之处,还是我应该将其作为模拟器错误忽略?
感谢您的回复。