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:
Bitmap
object in MAT, right-click onmBuffer
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
andmHeight
fields in MAT in attributes section as shown in image in question.You can convert memory dumps from MAT to png using with ImageMagick on command line.
In
MAT
for relatedBitmap
object right clickmBuffer
field and select "Copy" -> "Save Value To File", name the file with an.rgba
extension.You need to note bitmap width and height from
mWidth
andmHeight
fields, which you can see in Bitmap object.Having
ImageMagick
command line tools installed (for Ubuntuapt-get install imagemagick
), you issueconvert
command with the following parameters.For example
You can check generated png file via eog, like
eog phone_decor.rgba
onUbuntu
easily.