Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to actually see a Bitmap taken from an Android heap dump
    primarykey
    data
    text
    <p>In the process of tracking severe memory issues in my app, I looked at several heap dumps from my app, and most of the time I have a HUGE bitmap that I don't know of.</p> <p>It takes 9.4MB, or 9,830,400 bytes, or actually a 1280x1920 image at 4 bytes per pixels.</p> <p>I checked in Eclipse MAT, it is indeed a byte[9830400], that has one incoming reference which is a <code>android.graphics.Bitmap</code>.</p> <p>I'd like to dump this to a file and try to see it. I can't understand where is it coming from. My biggest image in all my drawables is a 640x960 png, which takes less than 3MB.</p> <p>I tried to use Eclipse to "copy value to file", but I think it simply prints the buffer to the file, and I don't know any image software that can read a stream of bytes and display it as a 4 bytes per pixel image.</p> <p>Any idea?</p> <p>Here's what I tried: dump the byte array to a file, push it to /sdcard/img, and load an activity like this:</p> <pre><code>@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { final File inputFile = new File("/sdcard/img"); final FileInputStream isr = new FileInputStream(inputFile); final Bitmap bmp = BitmapFactory.decodeStream(isr); ImageView iv = new ImageView(this); iv.setImageBitmap(bmp); setContentView(iv); Log.d("ImageTest", "Image was inflated"); } catch (final FileNotFoundException e) { Log.d("ImageTest", "Image was not inflated"); } } </code></pre> <p>I didn't see anything.</p> <p>Do you know how is encoded the image? Say it is stored into <code>byte[] buffer</code>. <code>buffer[0]</code> is red, <code>buffer[1]</code> is green, etc?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload