当我在性能分析模式下运行时,我的应用程序停止响应 [英] My app stops responding when I run it on the Profiling mode

查看:376
本文介绍了当我在性能分析模式下运行时,我的应用程序停止响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android应用程序的长时间运行会话中出现一些OutOfMemory错误.为了找到原因,我尝试使用Android Studio Profiler,但它停止工作并在使用后10秒钟内冻结了该应用程序.

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.

有一个Android Studio屏幕截图.它会在最初的几秒钟内记录活动,然后冻结应用程序并停止记录任何内容-> https://ibb.co/QXLhqnz

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

我的logcat的最后一行读取(随着时间的增加,最后一行不断重复,我更改了程序包名称)

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

任何帮助都感谢您.

推荐答案

Android Studio Profiler可能不是执行此任务的合适工具.首先使用 LeakCanary 识别可能的内存泄漏,并进行修复,那么您应该能够使用事件探查器,而不会导致线程停滞/中断.如果没有提供最少的代码,这可能是最好的答案.

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.

出现这种现象的原因可能是,ART杀死了停滞的线程,而探查器却一直在等待它们响应,这显然不会发生,因为它们已经不存在了.

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.

错误消息来自ART,请参阅 thread_list.cc .在Dalvik VM上,其行为可能有所不同(很可能是由于OOM导致强制关闭,否则可能会使VM崩溃).那可能值得一试.进行概要分析时也可以选择进入它,但是到目前为止,它不如LeakCanaray方便.

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.

更新:Android Studio 3.6.2发行说明指出:

Update: The Android Studio 3.6.2 release notes state:

使用探查器时,改进了活动和片段的内存泄漏检测.

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

这篇关于当我在性能分析模式下运行时,我的应用程序停止响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆