如何使用android studio分析内存 [英] How to analyze memory using android studio

查看:48
本文介绍了如何使用android studio分析内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近从eclipse切换到android studio.如何在android studio中检查应用程序堆和内存分配?在 Eclipse 中,我们有 MAT 工作室中是否有任何东西可以检查堆转储、hprof 文件?

解决方案

我会用简单的方法来解释它:

  1. 首先,您需要安装 MAT ( download ) 或使用:

    <块引用>

    brew cask install memoryanalyzer

  2. 在 Android Studio 中打开 Android Device Monitor 或 DDMS.

  3. 选择您的流程com.example.etc.."

  4. 点击进程列表上方的更新堆.

  5. 在右侧面板中,选择堆"选项卡.

  6. 点击 Cause GC.

  7. 单击进程列表上方的转储 HPROF 文件.

  8. 当我们下载文件 HPROF 时,我们必须打开终端并运行此命令以生成文件以使用 MAT 打开它.

  9. 打开终端并运行此命令

<块引用>

./hprof-conv path/file.hprof exitPath/heap-converted.hprof

命令hprof-conv"在sdk的platform-tools文件夹中.

  1. 并且ready和MAT可以打开和打开转换后的文件(heap-converted.hprof).

Recently switch to android studio from eclipse. How to check app heap and memory allocation in android studio? In Eclipse we have MAT is there anything in the studio to check heap dump, hprof file?

解决方案

I'll explain it in an easy way with steps:

  1. First, you have install MAT ( download ) or use:

    brew cask install memoryanalyzer

  2. In Android Studio open Android Device Monitor or DDMS.

  3. Select your process "com.example.etc.."

  4. Click Update Heap above the process list.

  5. In the right-side panel, select the Heap tab.

  6. Click in Cause GC.

  7. Click Dump HPROF file above the process list.

  8. When we downloaded the file HPROF, we have to open the Terminal and run this command to generate the file to open it with MAT.

  9. Open terminal and run this command

./hprof-conv path/file.hprof exitPath/heap-converted.hprof

The command "hprof-conv" is in the platform-tools folder of the sdk.

  1. And ready and MAT can open and open the converted file ( heap-converted.hprof ) .

这篇关于如何使用android studio分析内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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