MAT (Eclipse Memory Analyzer) - 如何从内存转储中查看位图 [英] MAT (Eclipse Memory Analyzer) - how to view bitmaps from memory dump

查看:17
本文介绍了MAT (Eclipse Memory Analyzer) - 如何从内存转储中查看位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在

  • 接下来,在 MAT 中找到您的 Bitmap 对象,右键单击 mBuffer 字段,在弹出菜单中选择 Copy" ->将值保存到文件" 菜单项并将此数组的值保存到某个文件中
  • 为该文件提供扩展名 .data
  • 启动 GIMP,选择 文件" -> 打开",选择您的 .data 文件并点击 Openem> 按钮
  • 从原始数据加载图像" 对话框将会出现.在这里你需要为你的位图设置正确的参数
  • 首先,选择图像类型"作为RGB Alpha"(大多数Android资源都有这种图像类型,但您可能需要尝试其他图像类型)
  • 第二,为您的位图设置正确的宽度高度(正确的尺寸可以在内存转储中找到)
  • 此时您应该已经观察到原始图像的预览.如果没有,您可以尝试在从原始数据加载图像" 对话框中更改一些其他参数.

    注意:要获得图像的宽度和高度,您可以查看属性部分中 MAT 中的 mWidthmHeight 字段,如相关图像所示.

    I'm analyzing memory usage of my Android app with help of Eclipse Memory Analyzer (also known as MAT). Sometimes I can find strange instances of android.graphics.Bitmap class, utilizing big portion of heap. Problem is what I can't find source of this bitmaps, no filename, no resourceID, nothing. All information what I can find for bitmap is following:

    There is a field mBuffer with array of image pixels, I assume. But it's in some internal Android format, not PNG.

    Question: how can I view image represented by this bitmap from memory dump?

    解决方案

    I have found a way to view such bitmaps:

    • First, you need to download and install GIMP
    • Next, find your Bitmap object in MAT, right-click on mBuffer field, in the popup menu choose "Copy" -> "Save Value To File" menu item and save value of this array to some file
    • give extension .data to that file
    • launch GIMP, choose "File" -> "Open", select your .data file and click Open button
    • "Load Image from Raw Data" dialog will appear. Here you need to set correct parameters for your bitmap
    • first, choose "Image type" as "RGB Alpha" (most Android resources have this image type, but you may need to experiment with other image types)
    • second, set correct Width and Height for your bitmap (correct dimensions can be found in the memory dump)

    At that point you should already observe preview of original image. If you didn't, you can try to change some other parameters in "Load Image from Raw Data" dialog.

    NOTE: to get a width and height of image you can look at mWidth and mHeight fields in MAT in attributes section as shown in image in question.

    这篇关于MAT (Eclipse Memory Analyzer) - 如何从内存转储中查看位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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