I use a jpeg in my Android App that takes up 1.6 MB on disk (on OSX). I noticed garbage collector warnings in the app logs, and took a heap dump in Android Studio. Out of a retained heap size of 36.5 MB, my home page fragment (this is the one with the jpeg) is taking up 36 MB.
I loaded the heap dump in Memory Analyzer Tool (MAT) and see a android.graphics.Bitmap taking up 36 MB of space in the heap. It's attribute view doesn't show the file name, but the dimensions match the 1.6 MB jpeg's dimensions.
How would an image that takes up less than 2 MB on disk take up 36 MB on an Android app's heap?
Thanks
JPEG is a compressed image format. To render it, Android needs to decompress it.