(仅限于)启动Android App时出现OutOfMemoryError

时间:2014-05-23 17:21:31

标签: java android out-of-memory

我差不多完成了我的第一款小型迷你游戏。但现在我遇到了一个问题:有时候,当我按下主页按钮并想要重新启动游戏时,它会崩溃并导致OutOfMemoryError - 但不是每次都会。我试图用onsurfacedestroyed()方法回收图像,但它并没有改变。我还在android:launchMode = "singleTask"文件的activity元素中添加了manifest - 仍然遇到了问题。

这是堆栈跟踪:

04-13 07:28:24.227: E/AndroidRuntime(1804): FATAL EXCEPTION: main
04-13 07:28:24.227: E/AndroidRuntime(1804): Process: de.lucid.mygame, PID: 1804
04-13 07:28:24.227: E/AndroidRuntime(1804): java.lang.OutOfMemoryError
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:575)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:410)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:433)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:463)
04-13 07:28:24.227: E/AndroidRuntime(1804): at de.lucid.mygame.views.PlayView$GameThread.<init>(PlayView.java:96)
04-13 07:28:24.227: E/AndroidRuntime(1804): at de.lucid.mygame.views.PlayView.restart(PlayView.java:346)
04-13 07:28:24.227: E/AndroidRuntime(1804): at de.lucid.mygame.activities.PlayActivity.onStart(PlayActivity.java:61)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.Activity.performStart(Activity.java:5253)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.Activity.performRestart(Activity.java:5309)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.Activity.performResume(Activity.java:5314)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2759)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2798)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1439)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.os.Handler.dispatchMessage(Handler.java:102)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.os.Looper.loop(Looper.java:137)
04-13 07:28:24.227: E/AndroidRuntime(1804): at android.app.ActivityThread.main(ActivityThread.java:4998)
04-13 07:28:24.227: E/AndroidRuntime(1804): at java.lang.reflect.Method.invokeNative(Native Method)
04-13 07:28:24.227: E/AndroidRuntime(1804): at java.lang.reflect.Method.invoke(Method.java:515)
04-13 07:28:24.227: E/AndroidRuntime(1804): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
04-13 07:28:24.227: E/AndroidRuntime(1804): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
04-13 07:28:24.227: E/AndroidRuntime(1804): at dalvik.system.NativeStart.main(Native Method)

有人可以帮我吗?

谢谢:)

0 个答案:

没有答案