我正在开发一个Android应用程序,现在我发现我的应用程序仅适用于API 22及更高版本的设备。在API小于22的所有设备(虚拟)中,它几乎在启动后立即崩溃(没有响应)。 我想这是因为内存不足而发生的。
如果我在" Memory"上查看Android监视器(在Android Studio中)图我可以看到 this,和 this
看起来android有足够的内存,但没有时间分配
如何在我的代码中找到确切的位置?
日志:
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
答案 0 :(得分:0)
如何在我的代码中找到确切的位置? - 调试!
深度调试后,我猜我发现了什么问题。 问题是我使用了自定义的ImageView并且占用了太多内存,因此我将尝试改进我的自定义ImageView。