Android发现死锁

时间:2011-03-16 02:33:40

标签: android deadlock

我运行Android服务时有时会收到ANR。我怀疑它是因为僵局而发生的。

是否有一种简单的方法来监控Android或Eclipse中的死锁。比如一个实用程序来显示哪个线程持有哪个锁等?

有没有办法通过查看traces.txt文件找出死锁?

我的ddms日志在崩溃时看起来像这样

02-15 18:09:01.046: INFO/Process(90): Sending signal. PID: 450 SIG: 3
02-15 18:09:01.046: INFO/dalvikvm(450): threadid=3: reacting to signal 3
02-15 18:09:01.056: INFO/dalvikvm(450): Wrote stack traces to '/data/anr/traces.txt'
02-15 18:09:01.076: INFO/Process(90): Sending signal. PID: 10548 SIG: 9
02-15 18:09:01.076: ERROR/ActivityManager(90): ANR in com.abc.cm.core
02-15 18:09:01.076: ERROR/ActivityManager(90): Reason: Executing service com.abc.cm.core/.WorkOrderManager
02-15 18:09:01.076: ERROR/ActivityManager(90): Load: 1.46 / 1.16 / 1.05
02-15 18:09:01.076: ERROR/ActivityManager(90): CPU usage from 19462ms to 1067ms ago:
02-15 18:09:01.076: ERROR/ActivityManager(90):   abc.cm.core: 13% = 12% user + 1% kernel / faults: 1360 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   mmcqd: 4% = 0% user + 4% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):   system_server: 3% = 2% user + 1% kernel / faults: 473 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   zygote: 2% = 2% user + 0% kernel / faults: 90 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   adbd: 1% = 0% user + 1% kernel / faults: 1042 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   m.abc.unten: 0% = 0% user + 0% kernel / faults: 203 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   ndroid.launcher: 0% = 0% user + 0% kernel / faults: 802 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   droid.wallpaper: 0% = 0% user + 0% kernel / faults: 109 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   ndroid.settings: 0% = 0% user + 0% kernel / faults: 44 minor
02-15 18:09:01.076: ERROR/ActivityManager(90):   dhd_dpc: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):   events/0: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):   logcat: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):  +andisk.api.test: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):  +iTestFwService1: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90):  +sh: 0% = 0% user + 0% kernel
02-15 18:09:01.076: ERROR/ActivityManager(90): TOTAL: 40% = 23% user + 16% kernel + 0% iowait + 0% softirq
02-15 18:09:01.096: INFO/ActivityManager(90): Process com.abc.cm.core (pid 10548) has died.

1 个答案:

答案 0 :(得分:0)

在任何平台上修复死锁都很困难。我在android上知道的唯一方法是在每次锁定/解锁/ otherExpensiveFunctions之前和之后添加一些日志记录(例如使用Log.d)