HeapWorker Android性能

时间:2011-01-07 06:43:55

标签: android performance dalvik

[ 01-01 08:29:02.954 1511:0x5e7 E/dalvikvm ]
HeapWorker is wedged: 10330ms spent inside Landroid/content/ContentResolver$CursorWrapperInner;.finalize()V
[ 01-01 08:29:02.954 1511:0x5e7 I/dalvikvm ]
DALVIK THREADS:    
[ 01-01 08:29:02.954 1511:0x5e7 I/dalvikvm ]
"main" prio=5 tid=1 RUNNABLE    
[ 01-01 08:29:02.954 1511:0x5e7 I/dalvikvm ]
  | group="main" sCount=0 dsCount=0 s=N obj=0x400258c8 self=0xcd98
[ 01-01 08:29:02.954 1511:0x5e7 I/dalvikvm ]
  | sysTid=1511 nice=0 sched=0/0 cgrp=default handle=-1345021912
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:Note: 0000662)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.lang.StringBuilder.toString(StringBuilder.java:664)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.io.File.join(File.java:264)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.io.File.<init>(File.java:175)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.io.File.<init>(File.java:142)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.io.File.filenamesToFiles(File.java:1082)
[ 01-01 08:29:02.977 1511:0x5e7 I/dalvikvm ]
  at java.io.File.listFiles(File.java:1008)

如何解决此问题?

我知道根本原因是要创建许多临时变量。

1 个答案:

答案 0 :(得分:3)

您正在查看错误线程的堆栈跟踪。

问题是终结器需要10秒以上才能完成,因此VM假定它已死锁并中止以使应用程序重新启动。在这种情况下,停滞的函数是android.content.ContentResolver.CursorWrapperInner.finalize()。

附近的HeapWorker线程应该有一个堆栈跟踪。