简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM