My app stops responding when I run it on the Profiling mode

我只是一个虾纸丫 提交于 2020-05-25 03:56:59

问题


I'm having a few OutOfMemory errors on long running sessions of my Android App. To find the cause I'm trying to use the Android Studio Profiler but it stops working and freezes the app within 10 seconds of use.

There's a screenshot of the Android Studio Screen. It logs the activities within the first seconds, then it just freezes the app and stops logging anything -> https://ibb.co/QXLhqnz

Last lines of my logcat reads (the last lines keep repeating with increasing time, I changed my package name)

2019-04-09 08:42:41.151 19728-20399/br.com.xxxxx V/StudioProfiler: Live memory tracking enabled.
2019-04-09 08:42:41.151 19728-20399/br.com.xxxxx V/StudioProfiler: JNIEnv not attached
2019-04-09 08:42:41.483 19728-20399/br.com.xxxxx V/StudioProfiler: Loaded classes: 8894
2019-04-09 08:42:51.688 19728-20399/br.com.xxxxx E/zygote: E[0]:Timed out waiting for threads to suspend(br.com.xxxxx), waited for 10.000s
2019-04-09 08:43:01.689 19728-20399/br.com.xxxxx E/zygote: E[0]:Timed out waiting for threads to suspend(br.com.xxxxx), waited for 20.000s
2019-04-09 08:43:11.689 19728-20399/br.com.xxxxx E/zygote: E[0]:Timed out waiting for threads to suspend(br.com.xxxxx), waited for 30.000s

Any help appreciated thanks in advance.


回答1:


The Android Studio Profiler might not be the proper tool for the task. First identify possible memory leaks with LeakCanary and fix them, then you should be able to use the Profiler, without having stalled/killed threads. Without the least code provided, this might be the best possible answer.

The reason for this behavior likely is, that the ART kills off stalled threads, while the Profiler keeps waiting for them to respond, which obviously will never happen, because they don't exist anymore.

The error message comes from ART, just see thread_list.cc. On Dalvik VM it might behave differently (most likely force-close due to OOM, or it may crash the VM). That might be worth a try. Stepping into it while profiling might also be an option, but it's by far not as handy as LeakCanaray.


Update: The Android Studio 3.6.2 release notes state:

Improved memory leak detection for your Activities and Fragments when using Profilers.



来源:https://stackoverflow.com/questions/55592239/my-app-stops-responding-when-i-run-it-on-the-profiling-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!