HY 我正在使用某个线程开发一个程序,有时我收到此错误消息:
11-03 18:58:06.047: I/dalvikvm(3587): threadid=15: stack overflow on call to Ljava/lang/ref/FinalizerReference;.<init>:VLL
11-03 18:58:06.047: I/dalvikvm(3587): method requires 12+20+12=44 bytes, fp is 0x591ad314 (20 left)
11-03 18:58:06.047: I/dalvikvm(3587): expanding stack end (0x591ad300 to 0x591ad000)
11-03 18:58:06.047: I/dalvikvm(3587): Shrank stack (to 0x591ad300, curFrame is 0x591ad328)
我使用此代码输出所有活动线程:
Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for(int i=0;i<threadArray.length;i++){
Log.e("Threadtest", threadArray[i].getName()+"|"+ threadArray[i].getClass()+"|"+ threadArray[i].getId());
}
这是输出:
11-03 18:58:02.847: E/Threadtest(3587): Signal Catcher|class java.lang.Thread|205
11-03 18:58:02.847: E/Threadtest(3587): Compiler|class java.lang.Thread|207
11-03 18:58:02.847: E/Threadtest(3587): FinalizerWatchdogDaemon|class java.lang.Thread|210
11-03 18:58:02.847: E/Threadtest(3587): pool-1-thread-1|class java.lang.Thread|217
11-03 18:58:02.847: E/Threadtest(3587): Binder_1|class java.lang.Thread|211
11-03 18:58:02.847: E/Threadtest(3587): ReferenceQueueDaemon|class java.lang.Thread|208
11-03 18:58:02.847: E/Threadtest(3587): Thread-224|class java.lang.Thread|224
11-03 18:58:02.847: E/Threadtest(3587): JDWP|class java.lang.Thread|206
11-03 18:58:02.847: E/Threadtest(3587): main|class java.lang.Thread|1
11-03 18:58:02.847: E/Threadtest(3587): Thread-214|class com.example.evosoft.ComUSB.Send.GCodeSender|214
11-03 18:58:02.847: E/Threadtest(3587): Thread-213|class com.example.evosoft.PrinterInfoSender|213
11-03 18:58:02.847: E/Threadtest(3587): Thread-215|class com.example.evosoft.ComUSB.UsbConnectionChecker|215
11-03 18:58:02.847: E/Threadtest(3587): GC|class java.lang.Thread|204
11-03 18:58:02.847: E/Threadtest(3587): Binder_2|class java.lang.Thread|212
11-03 18:58:02.847: E/Threadtest(3587): FinalizerDaemon|class java.lang.Thread|209
当我知道错误发生在哪个线程时,它会对我有所帮助。
最好的问候 马库斯