Mat (Eclipse Memory Analyzer) - How to View Bitmaps from Memory Dump

MAT (Eclipse Memory Analyzer) - how to view bitmaps 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.

How to open eclipse memory anaylzer index files in eclipse

Once you have installed MAT into Eclipse, open the Memory Analysis perspective and then do File > Open Heap Dump > "/home/rajkumar/Documents/heap-dump-ads03/testdump.hprof" and that will open the heap dump using the existing index files (so no reparsing is needed).
Then go to the toolbar 'Run Expert System Test' > 'Leak Suspects' to run the leak suspects report.

As suv3ndu said, you can also run the report from the command line. You can also open an existing report zip from the GUI using 'Run Expert System Test' > 'Open Report'.

How to use Eclipse Memory Analyser Tool (MAT) for analysing a hashmap

To answer my own question, I was trying to view the hprof file from Java/Debug Perspective. When I switch to Memory Analysis perspective, I could view the details of all objects, including key-value pairs for hashmap entries, in an Inspector -> Attributes window towards the left.

Edit: "key" attribute of the hashmap entries are still not visible. Only attributes of my custom hashmap entry object, which is the "value" part are visible. So, what I did is, for testing purpose, I put the key attribute (which is an integer), in the custom hashmap entry object, to be able to view it from the Inspector -> Attributes from the Memory Analysis perspective.

class TextCache{
Bitmap bitmap;
int left;
int right;
int keyCode;
int key; // this is actually the key used to insert objects of TextCache into the hashmap.
}

If anybody finds out, how to directly view the "key" part from the hprof file, it would be great.

Potential memory leak of bitmap reported by heap analysis tools but no bitmaps used by App

This bitmap is system-related and not a memory leak in the App. I came to this conclusion via posts Android EdgeEffect appears to allocate a 1 meg bitmap and Strange Bitmap using 1 Mb of Heap.

For anyone reading this I'd like to bring to your attention another very useful post that showed me how to view the bitmaps that are pointed to by the Eclipse Memory Analyzer tool. This can really help with debugging. See MAT (Eclipse Memory Analyzer) - how to view bitmaps from memory dump



Related Topics



Leave a reply



Submit