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?
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.
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).
I have found a way to view such bitmaps:
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.data
to that file.data
file and click Open buttonAt 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With