Android发现死锁

1rhkuytd  于 2022-12-31  发布在  Android
关注(0)|答案(1)|浏览(136)

当我运行我的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.
js81xvg6

js81xvg61#

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

相关问题