如何在 Android 中查找内存泄漏类/活动 [英] How to find Memory Leak Class/Activity in Android

查看:25
本文介绍了如何在 Android 中查找内存泄漏类/活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是这个 Android 平台的新手.在一个应用程序中,存在内存泄漏.但是我无法找到内存泄漏发生在哪个活动或类中.

I am New to this Android platfrom. In one application, there is a memory leak. But i couldn't able to find in which actiity or class the memory leak is happening.

我正在使用 MAT 来确认内存泄漏是否存在.但无法找到泄漏的活动.

I am using MAT to get the infirmation that the memory leak is there or not. But not able to find which activity is leaking.

请告诉我如何找到泄漏的活动.

Please tell me how to find the which activity is leaking.

谢谢.

推荐答案

即使这个问题很老.我认为带有图像的小教程可能会有所帮助.因此,首先您需要安装 MAT 插件.重启后点击转储 HPROF 文件:

Even if this question is quiet old. I think a small tutorial with images might be helpful. So first you need to install the MAT plugin. After a restart click on Dump HPROF file:

一段时间(大约 30 秒)后,您会看到一个对话框,您可以在其中单击完成".比你得到这个观点:

After some time (about 30 seconds) you'll get a dialog where you can click on finish. Than you get this view:

在那里您左键单击最大的部分并过滤外向参考.然后你会在这里看到这个视图:

There you left click on the biggest part and filter for with outgoing references. Then you get this view here:

在这里您可以看到,我错过了删除 ContentManager 中的项目,其中多个项目存储在我的 pending HashMap 中.

Here you can see that I missed to delete items in my ContentManager where several items were stored in my pending HashMap.

这篇关于如何在 Android 中查找内存泄漏类/活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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