1
私はアンドロイドアプリを開発していますが、私のアプリはAPI 22以上のデバイスでのみ正常に動作することがわかりました。 APIが22未満のすべてのデバイス(仮想)では、起動直後にクラッシュ(応答しない)します。 私はそれがメモリ不足のために起こると思います。Androidアプリケーションがメモリ不足のため応答しない
私は「メモリ」の図に(アンドロイドStudioの)タブのAndroidモニターを見れば、私はアンドロイドのに十分なメモリを持っていますが、ちょうど割り当てる時間を持っていないように見えます this、および this
を見ることができます
私のコード上で正確な場所を見つけるにはどうすればいいですか?
ログイン:
E/eglCodecCommon: writeFully: failed: Bad address
I/ActivityManager: Killing 1600:com.android.onetimeinitializer/u0a10 (adj 15): empty #17
W/libprocessgroup: failed to open /acct/uid_10010/pid_1600/cgroup.procs: No such file or directory
W/ActivityManager: Launch timeout has expired, giving up wake lock!
I/InputDispatcher: Application is not responding: Window{32b75f14 u0 .MainActivity}. It has been 5006.9ms since event, 5006.7ms since wait started. Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 11. Wait queue head age: 5549.6ms.
I/WindowManager: Input event dispatching timed out sending to .MainActivity. Reason: Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 11. Wait queue head age: 5549.6ms.
I/Process: Sending signal. PID: 1927 SIG: 3
I/art:Thread[5,tid=1934,WaitingInMainSignalCatcherLoop,Thread*=0xef70d400,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'
I/Process: Sending signal. PID: 764 SIG: 3
I/art: Thread[5,tid=771,WaitingInMainSignalCatcherLoop,Thread*=0xef70d400,peer=0x12c02080,"Signal Catcher"]: reacting to signal 3
E/Sensors: Select fail, disconnect all clients (errno=4)
I/art: Wrote stack traces to '/data/anr/traces.txt'
I/Process: Sending signal. PID: 1081 SIG: 3
10-15 14:59:59.410 1081-1089/com.android.phone I/art: Thread[5,tid=1089,WaitingInMainSignalCatcherLoop,Thread*=0xef70d400,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'
10-15 14:59:59.477 764-785/system_process I/Process: Sending signal. PID: 1050 SIG: 3
I/art: Thread[5,tid=1057,WaitingInMainSignalCatcherLoop,Thread*=0xef70d400,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'
I/Process: Sending signal. PID: 868 SIG: 3
I/art: Thread[5,tid=876,WaitingInMainSignalCatcherLoop,Thread*=0xef70d400,peer=0x12c00080,"Signal Catcher"]: reacting to signal 3
I/art: Wrote stack traces to '/data/anr/traces.txt'
I/art: Explicit concurrent mark sweep GC freed 39859(2MB) AllocSpace objects, 15(316KB) LOS objects, 33% free, 7MB/11MB, paused 367us total 18.175ms
E/ActivityManager: ANR in projectName
PID: 1927
Reason: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 11. Wait queue head age: 5549.6ms.)
Load: 0.19/0.05/0.02
CPU usage from 9247ms to 0ms ago:
2.3% 125/adbd: 0.1% user + 2.2% kernel/faults: 2072 minor
1.2% 764/system_server: 0.4% user + 0.8% kernel/faults: 239 minor
1.1% 1927/prjectName: 0.8% user + 0.3% kernel/faults: 731 minor
0.3% 303/local_opengl: 0% user + 0.3% kernel
0% 301/vinput: 0% user + 0% kernel
0.1% 1//init: 0% user + 0.1% kernel/faults: 9 minor
0.1% 8/rcu_preempt: 0% user + 0.1% kernel
0.1% 749/surfaceflinger: 0% user + 0.1% kernel
0.1% 1112/com.android.launcher3: 0.1% user + 0% kernel/faults: 377 minor
0.1% 1820/com.android.defcontainer: 0.1% user + 0% kernel/faults: 200 minor
1.5% TOTAL: 0.3% user + 1% kernel + 0% softer
CPU usage from 1802ms to 2307ms later with 99% awake:
3.9% 764/system_server: 0% user + 3.9% kernel/faults: 4 minor
1.4% TOTAL: 0.4% user + 0.4% kernel + 0.4% softirq
LeakCanaryというライブラリがあります。使用したことはありませんが、それについてはあとで触れました –
私たちは実際のデバイスについて言いますか?古いシステムは通常メモリが少なくて済むので、理由を特定するのは難しいことを忘れないでください。エミュレータで確認してください。あなたのAVDを作成するときに、あなたがそれを与えるどのくらいのメモリを選択することができます。 API 16や4GB以上の画像を読み込むと、まだそれが起こっているかどうかがわかります。 –
メモリに関連している可能性は非常に低いです。 apiレベルの低いデバイスでアプリのデバッグを試してみてください。また、あなたのアプリがログにクラッシュする原因となった例外のスタックトレースがあるはずです。正確に何が問題なのかを教えてください。 –