Я использую клиент Smack XMPP в пользовательском сервисе, и все идет хорошо ... до тех пор, пока у меня не появилось несколько отчетов о ANR с рынка Android.
Я читал много тем в StackOverflow, чтобы найти причину. Я также пытался читать следы и dumpstate ...
Я, наконец, думаю, что понял, почему это происходит и как я могу это воспроизвести. Похоже, какой-то телефон, как Galaxy S,
более чувствительны, чем другие Motorola Milestone и HTC Wildfire (у меня есть эти 3 устройства). Когда я специально загружаю приложения и возвращаюсь
для моего приложения, скорее всего, будет иметь ANR, особенно с использованием карт.
Моя проблема в том, что я понятия не имею, как с этим бороться, и как я могу избежать ANR,
например, функция, говорящая «будь осторожен, чувак, память почти заполнена», а затем ты можешь удалить службу (даже если я действительно не хочу ...)
Если вам нужны следы или дамп, просто спросите в комментариях, но я думаю, это более или менее бесполезно в моем случае.
Ура!
Update; Вот и мы, 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)