我的应用程序在第一次运行时运行良好,但如果我重新启动它会崩溃并让我强制关闭。在我按下强制关闭按钮后,我可以再次启动应用程序。如果我在按下后退按钮后尝试重新启动,我必须强制关闭。我让我每次尝试都运行它而不会出错。我认为 android 应该负责将内存返回给计算机,所以我们不必做那些家务:我确实有一个有点大的数组:
int worldgrid= new int[640][480][3];
在我的构造函数中,我可能不得不缩短它。我确实做了第一次尝试。记录猫消息:
05-08 19:09:46.035:E/dalvikvm-heap(420):28 字节分配内存不足。
05-08 19:09:46.195:我/dalvikvm(420):| group="main" sCount=0 dsCount=0 s=N obj=0x4001d8e0 self=0xccb0 05-08 19:09:46.195: I/dalvikvm(420): | sysTid=420 nice=0 sched=0/0 cgrp=默认句柄=-1345026008 05-08 19:09:46.205: I/dalvikvm(420): | schedstat=( 52616400652 22917249866 1196 ) 05-08 19:09:46.205: I/dalvikvm(420): at java.lang.reflect.Array.createMultiArray(Native Method) 05-08 19:09:46.205: I/dalvikvm( 420): at java.lang.reflect.Array.newInstance(Array.java:444) 05-08 19:09:46.455: I/dalvikvm(420): at com.gravedigger.MainGamePanel.(MainGamePanel.java:215) 05-08 19:09:46.455: I/dalvikvm(420): 在 com.digger.DiggerActivity.onCreate(GravediggerActivity.java:116) 05-08 19:09:46.615: I/dalvikvm(420): 在 android。 app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-08 19:09:46.625:
05-08 19:09:47.045: I/dalvikvm(420): | group="main" sCount=1 dsCount=0 s=N obj=0x4001d8e0 self=0xccb0 05-08 19:09:47.045: I/dalvikvm(420): | sysTid=420 nice=0 sched=0/0 cgrp=默认句柄=-1345026008 05-08 19:09:47.045: I/dalvikvm(420): | schedstat=( 52980087202 23270903160 1219 ) 05-08 19:09:47.045: I/dalvikvm(420): at java.lang.reflect.Array.createMultiArray(Native Method) 05-08 19:09:47.045: I/dalvikvm( 420): 在 java.lang.reflect.Array.newInstance(Array.java:444) 05-08 19:09:47.045: I/dalvikvm(420): 在 com.digger.MainGamePanel.(MainGamePanel.java:215) 05-08 19:09:47.045: I/dalvikvm(420): 在 com.digger.DiggerActivity.onCreate(GravediggerActivity.java:116) 05-08 19:09:47.045: I/dalvikvm(420): 在 android。 app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-08 19:09:47.185: I/dalvikvm(420): 在 java.lang.reflect.Method.invoke(Method.java:521) 05-08 19:09:47.195: I/dalvikvm(420): 在 com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:868) 05-08 19:09:47.195: I/dalvikvm(420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-08 19 :09:47.195: I/dalvikvm(420): at dalvik.system.NativeStart.main(Native Method) 05-08 19:09:47.195: I/dalvikvm(420): "Binder Thread #2" prio=5 tid =6 本地 05-08 19:09:47.195: I/dalvikvm(420): | group="main" sCount=1 dsCount=0 s=N obj=0x44f366b8 self=0x11d230 05-08 19:09:47.195: I/dalvikvm(420): | sysTid=425 nice=0 sched=0/0 cgrp=default 句柄=1297528 05-08 19:09:47.195: I/dalvikvm(420): | schedstat=(118912719 416670422 51) 05-08 19:09:47.195: I/dalvikvm(420): 在 dalvik.system.NativeStart。运行(本机方法)05-08 19:09:47.195:I/dalvikvm(420):“Binder Thread #1”prio=5 tid=5 NATIVE 05-08 19:09:47.195:I/dalvikvm(420): | group="main" sCount=1 dsCount=0 s=N obj=0x44f36480 self=0x11fd80 05-08 19:09:47.750: I/dalvikvm(420): | sysTid=424 nice=0 sched=0/0 cgrp=default 句柄=1269616 05-08 19:09:47.750: I/dalvikvm(420): | schedstat=( 114332827 305656917 35 ) 05-08 19:09:47.750: I/dalvikvm(420): at dalvik.system.NativeStart.run(Native Method) 05-08 19:09:47.755: I/dalvikvm(420) :“JDWP”守护进程prio=5 tid=4 VMWAIT 05-08 19:09:47.755:I/dalvikvm(420):| group="system" sCount=1 dsCount=0 s=N obj=0x44f352a0 self=0x135ad0 05-08 19:09:47.755: I/dalvikvm(420): | sysTid=423 nice=0 sched=0/0 cgrp=默认句柄=1196352 05-08 19:09:47.765: I/dalvikvm(420): | schedstat=( 59551849 158373474 18 ) 05-08 19:09:47.765: I/dalvikvm(420): at dalvik.system.NativeStart.run(Native Method) 05-08 19:09:47.775: I/dalvikvm(420) :“信号捕手”守护进程prio=5 tid=3 VMWAIT 05-08 19:09:47.886:I/dalvikvm(420):| group="system" sCount=1 dsCount=0 s=N obj=0x44f351e8 self=0x125550 05-08 19:09:47.886: I/dalvikvm(420): | sysTid=422 nice=0 sched=0/0 cgrp=default 句柄=1240608 05-08 19:09:47.886: I/dalvikvm(420): | schedstat=( 2639901 40055709 3 ) 05-08 19:09:47.886: I/dalvikvm(420): at dalvik.system.NativeStart.run(Native Method) 05-08 19:09:47.886: I/dalvikvm(420) : "HeapWorker" 守护进程 prio=5 tid=2 RUNNABLE 05-08 19:09:47.886: I/dalvikvm(420): | group="system" sCount=0 dsCount=0 s=N obj=0x438b8e50 self=0x12ece0 05-08 19:09:47.886: 我/dalvikvm(420):| sysTid=421 nice=0 sched=0/0 cgrp=default 句柄=1195896 05-08 19:09:47.906: I/dalvikvm(420): | schedstat=( 4477669539 2785983510 211 ) 05-08 19:09:47.906: I/dalvikvm(420): at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:~48) 05-08 19: 09:47.906: I/dalvikvm(420): at dalvik.system.NativeStart.run(Native Method) 05-08 19:09:47.906: D/dalvikvm(420): threadid=2: 发送两个 SIGSTKFLTs 到 threadid=2 (tid=421) 导致调试器转储 05-08 19:09:57.895: D/dalvikvm(420): 发送,暂停让调试器运行 05-08 19:10:05.956: D/dalvikvm(420): 继续 05 -08 19:10:05.956:E/dalvikvm(420):VM 中止