Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 364
Pedro Malta Avatar asked Apr 09 '19 11:04

Pedro Malta


People also ask

How to solve the app not responding issue?

Many times a simple clean boot has solved the app not responding issue for me. A clean boot ensures no startup app or service is conflicting with the not responding app. To clean boot Windows 10, press Windows + R keys and type msconfig in the Run dialog to open the System Configuration window.

Why do apps stop working suddenly on Android?

Another reason for Apps to stop working could be corrupted Cache files, which have not been cleared in a long time. Many users also feel that incomplete or improper installation may cause the App to crash and stop working suddenly.

Why does my app keep crashing and stopping?

Many users also feel that incomplete or improper installation may cause the App to crash and stop working suddenly. There may be many more reasons for them; unfortunately, App has stopped error to show up, but no one reason can be blamed for it.

What to do if an app is not working on iPhone?

Then redownload the app. Then check to see if the problem with the app is fixed. If the App Store itself is not responding, contact Apple Support for your iPhone or for your iPad. If you found the app on the App Store, contact the app developer.


1 Answers

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.

like image 123
Martin Zeitler Avatar answered Nov 16 '22 19:11

Martin Zeitler