我的Android应用很少冻结。问题不在于应用程序冻结,而是问题是它非常(非常)很少发生,因此很难再现它。另外,为了让思考变得复杂,它在应用程序的任何地方都会随机出现并采取行动,因此也很难知道所涉及的算法。
当应用程序冻结它们时,它会在日志中显示:
03-11 12:11:12.475:I / art(15973):将堆栈跟踪写入' /data/anr/traces.txt'
但不幸的是我不知道它是否有用,因为我在traces.txt中有这样的想法:
----- pid 9683 at 2017-03-11 16:35:27 -----
Cmd line: monster.app
ABI: arm
Build type: optimized
Zygote loaded classes=3073 post zygote classes=17986
Intern table: 5267 strong; 6 weak
JNI: CheckJNI is on; globals=1105 (plus 1 weak)
Libraries: /system/lib/libandroid.so /system/lib/libandroid_runtime.so /system/lib/libaudioeffect_jni.so /system/lib/libcompiler_rt.so /system/lib/libjavacrypto.so /system/lib/libjnigraphics.so /system/lib/libknoxvpnfdsender.so /system/lib/libmedia_jni.so /system/lib/librs_jni.so /system/lib/libsoundpool.so /system/lib/libwebviewchromium_loader.so libjavacore.so (12)
Heap: 39% free, 16MB/27MB; 54477 objects
Dumping cumulative Gc timings
Total number of allocations 642996
Total bytes allocated 41MB
Free memory 10MB
Free memory until GC 10MB
Free memory until OOME 111MB
Total memory 27MB
Max memory 128MB
Total mutator paused time: 0
Total time waiting for GC to complete: 1.136ms
DALVIK THREADS (22):
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 obj=0x76843000 self=0x42827800
| sysTid=9683 nice=0 cgrp=default sched=0/0 handle=0x40014bec
| state=S schedstat=( 258748837 74521998 332 ) utm=10 stm=15 core=2 HZ=100
| stack=0xbe78f000-0xbe791000 stackSize=8MB
| held mutexes=
native: #00 pc 00013418 /system/lib/libc.so (syscall+28)
native: #01 pc 00017539 /system/lib/libc.so (_Z33__pthread_cond_timedwait_relativeP14pthread_cond_tP15pthread_mutex_tPK8timespec+56)
native: #02 pc 00504855 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #03 pc 008400f1 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #04 pc 008401e3 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #05 pc 00068a93 /system/lib/libandroid_runtime.so (???)
native: #06 pc 002443bf /system/framework/arm/boot.oat (Java_android_app_NativeActivity_onStartNative__J+90)
at android.app.NativeActivity.onStartNative(Native method)
at android.app.NativeActivity.onStart(NativeActivity.java:230)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1264)
at android.app.Activity.performStart(Activity.java:6613)
at android.app.Activity.performRestart(Activity.java:6683)
at android.app.ActivityThread.handleSleeping(ActivityThread.java:4678)
at android.app.ActivityThread.access$3500(ActivityThread.java:211)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1934)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6912)
at java.lang.reflect.Method.invoke!(Native method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
"Signal Catcher" daemon prio=5 tid=2 Runnable
| group="system" sCount=0 dsCount=0 obj=0x12c370a0 self=0x68491c00
| sysTid=9688 nice=0 cgrp=default sched=0/0 handle=0x42915d00
| state=R schedstat=( 460323992 55299544 78 ) utm=30 stm=16 core=3 HZ=100
| stack=0x62fcc000-0x62fce000 stackSize=1012KB
| held mutexes= "thread list lock" "mutator lock"(exclusive held)
native: #00 pc 00004e04 /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
native: #01 pc 00003631 /system/lib/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEjP8ucontext+8)
native: #02 pc 00266559 /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiPKcPNS_6mirror9ArtMethodE+84)
native: #03 pc 002485cf /system/lib/libart.so (_ZNK3art6Thread4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+158)
native: #04 pc 00251f2d /system/lib/libart.so (_ZN3art10ThreadList14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+160)
native: #05 pc 002364d7 /system/lib/libart.so (_ZN3art7Runtime14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+74)
native: #06 pc 0023cd83 /system/lib/libart.so (_ZN3art13SignalCatcher13HandleSigQuitEv+782)
native: #07 pc 0023d499 /system/lib/libart.so (_ZN3art13SignalCatcher3RunEPv+396)
native: #08 pc 00017667 /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: #09 pc 00015683 /system/lib/libc.so (__start_thread+6)
(no managed stack frames)
"JDWP" daemon prio=5 tid=3 WaitingInMainDebuggerLoop
| group="system" sCount=1 dsCount=0 obj=0x12c390a0 self=0x42827400
| sysTid=9690 nice=0 cgrp=default sched=0/0 handle=0x42915f80
| state=S schedstat=( 4406542 8505416 10 ) utm=0 stm=0 core=0 HZ=100
| stack=0x630ca000-0x630cc000 stackSize=1012KB
| held mutexes=
native: #00 pc 0003ac54 /system/lib/libc.so (__pselect6+20)
native: #01 pc 00016dff /system/lib/libc.so (select+60)
native: #02 pc 002a94e3 /system/lib/libart.so (_ZN3art4JDWP12JdwpAdbState15ProcessIncomingEv+202)
native: #03 pc 001a3af5 /system/lib/libart.so (_ZN3art4JDWP9JdwpState3RunEv+356)
native: #04 pc 001a5041 /system/lib/libart.so (_ZN3art4JDWPL15StartJdwpThreadEPv+16)
native: #05 pc 00017667 /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: #06 pc 00015683 /system/lib/libc.so (__start_thread+6)
(no managed stack frames)
"Binder_1" prio=5 tid=4 Native
| group="main" sCount=1 dsCount=0 obj=0x12c540a0 self=0x6849dc00
| sysTid=9692 nice=0 cgrp=default sched=0/0 handle=0x42915080
| state=S schedstat=( 72670502 89835456 450 ) utm=3 stm=4 core=3 HZ=100
| stack=0x633ca000-0x633cc000 stackSize=1012KB
| held mutexes=
native: #00 pc 0003b87c /system/lib/libc.so (__ioctl+8)
native: #01 pc 00052bcd /system/lib/libc.so (ioctl+14)
native: #02 pc 0001f5db /system/lib/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+138)
native: #03 pc 0001fadb /system/lib/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+6)
native: #04 pc 0001fb3d /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+48)
native: #05 pc 00023cdf /system/lib/libbinder.so (???)
native: #06 pc 000106a9 /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)
native: #07 pc 00065399 /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+72)
native: #08 pc 00010219 /system/lib/libutils.so (???)
native: #09 pc 00017667 /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: #10 pc 00015683 /system/lib/libc.so (__start_thread+6)
(no managed stack frames)
"ReferenceQueueDaemon" daemon prio=5 tid=5 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c560a0 self=0x42828c00
| sysTid=9694 nice=0 cgrp=default sched=0/0 handle=0x42915a80
| state=S schedstat=( 9677585 5269625 35 ) utm=0 stm=0 core=0 HZ=100
| stack=0x635c6000-0x635c8000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x0fad16c1> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:149)
- locked <0x0fad16c1> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Thread.run(Thread.java:818)
"FinalizerWatchdogDaemon" daemon prio=5 tid=6 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c56160 self=0x4282b000
| sysTid=9696 nice=0 cgrp=default sched=0/0 handle=0x42917b00
| state=S schedstat=( 2091793 7131166 14 ) utm=0 stm=0 core=0 HZ=100
| stack=0x637ce000-0x637d0000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x03e7ae66> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Daemons$FinalizerWatchdogDaemon.waitForObject(Daemons.java:255)
- locked <0x03e7ae66> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:227)
at java.lang.Thread.run(Thread.java:818)
"GCDaemon" daemon prio=5 tid=7 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c56220 self=0x4282c800
| sysTid=9698 nice=0 cgrp=default sched=0/0 handle=0x42918000
| state=S schedstat=( 115822252 89330166 109 ) utm=9 stm=2 core=2 HZ=100
| stack=0x639d6000-0x639d8000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x09ac85a7> (a java.lang.Daemons$GCDaemon)
at java.lang.Daemons$GCDaemon.run(Daemons.java:359)
- locked <0x09ac85a7> (a java.lang.Daemons$GCDaemon)
at java.lang.Thread.run(Thread.java:818)
"Binder_2" prio=5 tid=8 Native
| group="main" sCount=1 dsCount=0 obj=0x12c56280 self=0x6849ec00
| sysTid=9693 nice=0 cgrp=default sched=0/0 handle=0x685a1800
| state=S schedstat=( 68144590 96143825 419 ) utm=0 stm=6 core=2 HZ=100
| stack=0x634c8000-0x634ca000 stackSize=1012KB
| held mutexes=
native: #00 pc 0003b87c /system/lib/libc.so (__ioctl+8)
native: #01 pc 00052bcd /system/lib/libc.so (ioctl+14)
native: #02 pc 0001f5db /system/lib/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+138)
native: #03 pc 0001fadb /system/lib/libbinder.so (_ZN7android14IPCThreadState20getAndExecuteCommandEv+6)
native: #04 pc 0001fb3d /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb+48)
native: #05 pc 00023cdf /system/lib/libbinder.so (???)
native: #06 pc 000106a9 /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)
native: #07 pc 00065399 /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+72)
native: #08 pc 00010219 /system/lib/libutils.so (???)
native: #09 pc 00017667 /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: #10 pc 00015683 /system/lib/libc.so (__start_thread+6)
(no managed stack frames)
"FinalizerDaemon" daemon prio=5 tid=9 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c56100 self=0x4282ac00
| sysTid=9695 nice=0 cgrp=default sched=0/0 handle=0x42916480
| state=S schedstat=( 22757334 21027290 22 ) utm=1 stm=0 core=2 HZ=100
| stack=0x636ca000-0x636cc000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x3557fa54> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:422)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:101)
- locked <0x3557fa54> (a java.lang.ref.ReferenceQueue)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:72)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:189)
at java.lang.Thread.run(Thread.java:818)
"HeapTrimmerDaemon" daemon prio=5 tid=10 Waiting
| group="system" sCount=1 dsCount=0 obj=0x12c561c0 self=0x4282c400
| sysTid=9697 nice=0 cgrp=default sched=0/0 handle=0x42917d80
| state=S schedstat=( 5942290 14618418 14 ) utm=0 stm=0 core=3 HZ=100
| stack=0x638d2000-0x638d4000 stackSize=1036KB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x35b35dfd> (a java.lang.Daemons$HeapTrimmerDaemon)
at java.lang.Daemons$HeapTrimmerDaemon.run(Daemons.java:326)
- locked <0x35b35dfd> (a java.lang.Daemons$HeapTrimmerDaemon)
at java.lang.Thread.run(Thread.java:818)
"Thread-2387" prio=5 tid=11 Native
| group="main" sCount=1 dsCount=0 obj=0x12d4f0a0 self=0x4282dc00
| sysTid=9736 nice=0 cgrp=default sched=0/0 handle=0x42915300
| state=R schedstat=( 279088258209 2791653221 7125 ) utm=2605 stm=25303 core=4 HZ=100
| stack=0x631ce000-0x631d0000 stackSize=1012KB
| held mutexes=
native: #00 pc 00261ca5 /system/lib/libart.so (_ZN3artL17art_fault_handlerEiP7siginfoPv)
native: #01 pc 0001329c /system/lib/libc.so (???)
native: #02 pc 0001329c /system/lib/libc.so (???)
native: #03 pc 0001329c /system/lib/libc.so (???)
native: #04 pc 0001329c /system/lib/libc.so (???)
native: #05 pc 0001329c /system/lib/libc.so (???)
native: #06 pc 0001329c /system/lib/libc.so (???)
native: #07 pc 0001329c /system/lib/libc.so (???)
native: #08 pc 0001329c /system/lib/libc.so (???)
native: #09 pc 0001329c /system/lib/libc.so (???)
native: #10 pc 0001329c /system/lib/libc.so (???)
native: #11 pc 0001329c /system/lib/libc.so (???)
native: #12 pc 0001329c /system/lib/libc.so (???)
native: #13 pc 0001329c /system/lib/libc.so (???)
native: #14 pc 0001329c /system/lib/libc.so (???)
native: #15 pc 0001329c /system/lib/libc.so (???)
native: #16 pc 0001329c /system/lib/libc.so (???)
native: #17 pc 0001329c /system/lib/libc.so (???)
native: #18 pc 0001329c /system/lib/libc.so (???)
native: #19 pc 0001329c /system/lib/libc.so (???)
native: #20 pc 0001329c /system/lib/libc.so (???)
native: #21 pc 0001329c /system/lib/libc.so (???)
native: #22 pc 0001329c /system/lib/libc.so (???)
native: #23 pc 0001329c /system/lib/libc.so (???)
native: #24 pc 0001329c /system/lib/libc.so (???)
native: #25 pc 0001329c /system/lib/libc.so (???)
native: #26 pc 0001329c /system/lib/libc.so (???)
native: #27 pc 0001329c /system/lib/libc.so (???)
native: #28 pc 0001329c /system/lib/libc.so (???)
native: #29 pc 0001329c /system/lib/libc.so (???)
native: #30 pc 0001329c /system/lib/libc.so (???)
native: #31 pc 0001329c /system/lib/libc.so (???)
native: #32 pc 0001329c /system/lib/libc.so (???)
native: #33 pc 0001329c /system/lib/libc.so (???)
native: #34 pc 0001329c /system/lib/libc.so (???)
native: #35 pc 0001329c /system/lib/libc.so (???)
native: #36 pc 0001329c /system/lib/libc.so (???)
native: #37 pc 0001329c /system/lib/libc.so (???)
native: #38 pc 0001329c /system/lib/libc.so (???)
native: #39 pc 0001329c /system/lib/libc.so (???)
native: #40 pc 0001329c /system/lib/libc.so (???)
native: #41 pc 0001329c /system/lib/libc.so (???)
native: #42 pc 0001329c /system/lib/libc.so (???)
native: #43 pc 0001329c /system/lib/libc.so (???)
native: #44 pc 0001329c /system/lib/libc.so (???)
native: #45 pc 0001329c /system/lib/libc.so (???)
native: #46 pc 0001329c /system/lib/libc.so (???)
native: #47 pc 0001329c /system/lib/libc.so (???)
native: #48 pc 0001329c /system/lib/libc.so (???)
native: #49 pc 0001329c /system/lib/libc.so (???)
native: #50 pc 0001329c /system/lib/libc.so (???)
native: #51 pc 0001329c /system/lib/libc.so (???)
native: #52 pc 0001329c /system/lib/libc.so (???)
native: #53 pc 0001329c /system/lib/libc.so (???)
native: #54 pc 0001329c /system/lib/libc.so (???)
native: #55 pc 0001329c /system/lib/libc.so (???)
native: #56 pc 0001329c /system/lib/libc.so (???)
native: #57 pc 0001329c /system/lib/libc.so (???)
native: #58 pc 0001329c /system/lib/libc.so (???)
native: #59 pc 0001329c /system/lib/libc.so (???)
native: #60 pc 0001329c /system/lib/libc.so (???)
native: #61 pc 0001329c /system/lib/libc.so (???)
native: #62 pc 0001329c /system/lib/libc.so (???)
native: #63 pc 0001329c /system/lib/libc.so (???)
(no managed stack frames)
"Thread-2388" prio=5 tid=12 Native
| group="main" sCount=1 dsCount=0 obj=0x12d730a0 self=0x42836800
| sysTid=9780 nice=0 cgrp=default sched=0/0 handle=0x42919400
| state=S schedstat=( 393555710 72387335 116 ) utm=13 stm=25 core=3 HZ=100
| stack=0x682ac000-0x682ae000 stackSize=1012KB
| held mutexes=
native: #00 pc 00013418 /system/lib/libc.so (syscall+28)
native: #01 pc 00017ecf /system/lib/libc.so (__futex_wait_ex+42)
native: #02 pc 00053031 /system/lib/libc.so (sem_wait+50)
native: #03 pc 00505a45 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #04 pc 005369b1 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #05 pc 00536cf3 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #06 pc 004eeee7 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #07 pc 004dbbe9 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #08 pc 00631cbb /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #09 pc 005f13cf /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #10 pc 00dbb2d1 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #11 pc 00dac8f5 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #12 pc 00631361 /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #13 pc 004f221b /data/app/monster.app-2/lib/arm/libmonster.so (???)
native: #14 pc 00017667 /system/lib/libc.so (_ZL15__pthread_startPv+30)
native: #15 pc 00015683 /system/lib/libc.so (__start_thread+6)
(no managed stack frames)
....