我在定制服务中使用Smack XMPP客户端,一切顺利......直到我从Android市场获得一些ANR报告。 我一直在阅读很多StackOverflow的主题,以找出可能的原因。我也试着读取痕迹和转储状态...... 我终于想到我已经理解为什么会发生这种情况以及如何重现它。它看起来像一些手机,如Galaxy S, 比其他摩托罗拉Milestone和HTC Wildfire更敏感(我有这3款设备)。当我加载目标大量的应用程序,然后回来 在我的应用程序中,它更可能有ANR,尤其是使用地图。
我的问题是,我不知道如何处理,以及如何避免ANR, 例如,一个功能说“小心老兄,内存几乎已满”,然后你可以删除服务(即使我真的不想要它......)
如果你想要追踪或转储,只需在评论中提问,但我想这在我的情况下或多或少是无用的。
干杯!
更新;在这里,Go,StackTrace:
11-24 17:20:25.357 I/am_anr ( 2479): [22962,com.meetme.android.activities,48708,Executing service com.meetme.android.activities/com.meetme.android.service.XmppService]
------ VM TRACES AT LAST ANR (/data/anr/traces.txt: 2011-11-24 17:20:26) ------
DALVIK THREADS:
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4001d8b0 self=0xcd30
| sysTid=22962 nice=0 sched=0/0 cgrp=default handle=-1345017808
| schedstat=( 20241984823 12130991031 35574 )
at java.lang.Object.wait(Native Method)
- waiting on <0x48000f68> (a android.os.MessageQueue)
at java.lang.Object.wait(Object.java:288)
at android.os.MessageQueue.next(MessageQueue.java:146)
at android.os.Looper.loop(Looper.java:110)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
"DispatcherThread" prio=5 tid=14 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x48350d20 self=0x609528
| sysTid=23150 nice=0 sched=0/0 cgrp=default handle=6329960
| schedstat=( 482871 9604514 3 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4828e450> (a android.os.MessageQueue)
at java.lang.Object.wait(Object.java:288)
at android.os.MessageQueue.next(MessageQueue.java:146)
at android.os.Looper.loop(Looper.java:110)
at android.os.HandlerThread.run(HandlerThread.java:60)
"Timer-14" prio=5 tid=15 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4804a2f8 self=0x291818
| sysTid=23147 nice=0 sched=0/0 cgrp=default handle=7785080
| schedstat=( 232664 3847398 4 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4804a2f8> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:288)
at java.util.Timer$TimerImpl.run(Timer.java:219)
"Timer-13" prio=5 tid=16 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4818f4b8 self=0x60d0d0
| sysTid=23143 nice=0 sched=0/0 cgrp=default handle=8388112
| schedstat=( 157746 13991968 4 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4818f4b8> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:288)
at java.util.Timer$TimerImpl.run(Timer.java:219)
"Smack Listener Processor (1)" daemon prio=5 tid=26 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x482937b0 self=0x7e6290
| sysTid=23140 nice=0 sched=0/0 cgrp=default handle=6353344
| schedstat=( 1789199 14773003 12 )
at java.lang.Object.wait(Native Method)
- waiting on <0x482939e0> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"Smack Keep Alive (1)" daemon prio=5 tid=25 TIMED_WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x482a50e0 self=0x7e7080
| sysTid=23139 nice=0 sched=0/0 cgrp=default handle=8286656
| schedstat=( 207789 1223315 3 )
at java.lang.VMThread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1306)
at java.lang.Thread.sleep(Thread.java:1286)
at org.jivesoftware.smack.PacketWriter$KeepAliveTask.run(PacketWriter.java:451)
at java.lang.Thread.run(Thread.java:1096)
"Smack Packet Reader (1)" daemon prio=5 tid=24 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x482003d8 self=0x7db9d8
| sysTid=23138 nice=0 sched=0/0 cgrp=default handle=8239896
| schedstat=( 8964691 15593096 48 )
at org.apache.harmony.luni.platform.OSNetworkSystem.readSocketImpl(Native Method)
at org.apache.harmony.luni.platform.OSNetworkSystem.read(OSNetworkSystem.java:358)
at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:561)
at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:88)
at java.io.InputStreamReader.read(InputStreamReader.java:275)
at java.io.BufferedReader.read(BufferedReader.java:338)
at org.kxml2.io.KXmlParser.peek(KXmlParser.java:931)
at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:589)
at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:333)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:1385)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:368)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)
"Smack Packet Writer (1)" daemon prio=5 tid=21 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x48274808 self=0x800a18
| sysTid=23137 nice=0 sched=0/0 cgrp=default handle=8391512
| schedstat=( 4035424 2055217 34 )
at java.lang.Object.wait(Native Method)
- waiting on <0x48274790> (a java.util.concurrent.ArrayBlockingQueue)
at java.lang.Object.wait(Object.java:288)
at org.jivesoftware.smack.PacketWriter.nextPacket(PacketWriter.java:239)
at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:255)
at org.jivesoftware.smack.PacketWriter.access$000(PacketWriter.java:40)
at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:87)
"Timer-4" prio=5 tid=20 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x480d4220 self=0x7fffe0
| sysTid=23123 nice=0 sched=0/0 cgrp=default handle=6557936
| schedstat=( 174580 10994824 3 )
at java.lang.Object.wait(Native Method)
- waiting on <0x480d4220> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:288)
at java.util.Timer$TimerImpl.run(Timer.java:219)
"Binder Thread #3" prio=5 tid=19 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x48172aa8 self=0x67dbe8
| sysTid=23059 nice=0 sched=0/0 cgrp=default handle=7217208
| schedstat=( 61468336 98741186 263 )
at dalvik.system.NativeStart.run(Native Method)
"Timer-2" prio=5 tid=9 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x481cc450 self=0x5f92b8
| sysTid=23044 nice=0 sched=0/0 cgrp=default handle=6124424
| schedstat=( 3747116 7045008 8 )
at java.lang.Object.wait(Native Method)
- waiting on <0x481cc450> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:288)
at java.util.Timer$TimerImpl.run(Timer.java:219)
"AsyncTask #5" prio=5 tid=13 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4810d888 self=0x2b7ad0
| sysTid=22976 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2849808
| schedstat=( 2703400040 4409206985 2479 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4810da80> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"AsyncTask #4" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4810d6e0 self=0x2b5f20
| sysTid=22975 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2842720
| schedstat=( 2980400404 5043212188 12529 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4810d838> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"AsyncTask #3" prio=5 tid=11 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4810d4a0 self=0x2b5318
| sysTid=22974 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2842200
| schedstat=( 2325671917 4252091750 5008 )
at java.lang.Object.wait(Native Method)
- waiting on <0x4810d5f8> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"AsyncTask #2" prio=5 tid=10 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x481088d0 self=0x2b43b0
| sysTid=22973 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2834960
| schedstat=( 2162608466 3503692881 5444 )
at java.lang.Object.wait(Native Method)
- waiting on <0x48108a28> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"AsyncTask #1" prio=5 tid=8 WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x4802d5a0 self=0x268df0
| sysTid=22970 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2712144
| schedstat=( 2947433374 4855945812 6110 )
at java.lang.Object.wait(Native Method)
- waiting on <0x47ffb6f0> (a java.lang.VMThread)
at java.lang.Thread.parkFor(Thread.java:1535)
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48)
at sun.misc.Unsafe.park(Unsafe.java:317)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:131)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1996)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:359)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1001)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
at java.lang.Thread.run(Thread.java:1096)
"CacheManagerEraser" prio=5 tid=7 TIMED_WAIT
| group="main" sCount=1 dsCount=0 s=N obj=0x480375c0 self=0x24e3c0
| sysTid=22968 nice=0 sched=0/0 cgrp=default handle=2416880
| schedstat=( 159612334 51354720 52 )
at java.lang.VMThread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1306)
at java.lang.Thread.sleep(Thread.java:1286)
at com.meetme.android.datamanager.CacheManager$1.run(CacheManager.java:178)
"Binder Thread #2" prio=5 tid=6 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x48004cf8 self=0x13fa98
| sysTid=22967 nice=0 sched=0/0 cgrp=default handle=1170896
| schedstat=( 133957060 207385468 521 )
at dalvik.system.NativeStart.run(Native Method)
"Binder Thread #1" prio=5 tid=5 NATIVE
| group="main" sCount=1 dsCount=0 s=N obj=0x48001798 self=0x11ca00
| sysTid=22966 nice=0 sched=0/0 cgrp=default handle=1164656
| schedstat=( 132801475 181256274 516 )
at dalvik.system.NativeStart.run(Native Method)
"Compiler" daemon prio=5 tid=4 VMWAIT
| group="system" sCount=1 dsCount=0 s=N obj=0x47ffa2a0 self=0x123998
| sysTid=22965 nice=0 sched=0/0 cgrp=default handle=1189920
| schedstat=( 2230570974 894018700 22290 )
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
| group="system" sCount=0 dsCount=0 s=N obj=0x47ffa1e8 self=0x122698
| sysTid=22964 nice=0 sched=0/0 cgrp=default handle=1271872
| schedstat=( 60947251 71847193 19 )
at dalvik.system.NativeStart.run(Native Method)
"HeapWorker" daemon prio=5 tid=2 VMWAIT
| group="system" sCount=1 dsCount=0 s=N obj=0x4524d7f0 self=0x11ce90
| sysTid=22963 nice=0 sched=0/0 cgrp=default handle=1252504
| schedstat=( 922251554 405119813 1365 )
at dalvik.system.NativeStart.run(Native Method)