Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAT (Eclipse Memory Analyzer) - how to view bitmaps from memory dump

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: bitmap_info

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?

like image 798
HitOdessit Avatar asked Oct 03 '12 13:10

HitOdessit


People also ask

How do I open memory analyzer in Eclipse?

With the Memory Analyzer feature installed, try Window -> Open Perspective -> Other... , then select Memory Analyzer and OK. Once the MA perspecive is open, one should be able to see the Memory Analyzer specific Eclipse menus.

How do I install memory analyzer tool?

Install Eclipse MAT via the Help Install New Software… ​ menu entry. Select the update site of your release from the drop-down box and once its content is downloaded, select General Purpose Tools and its sub-entries Memory Analyzer and Memory Analyzer(Charts).


1 Answers

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.

like image 85
HitOdessit Avatar answered Sep 19 '22 21:09

HitOdessit