I am guessing there is an obvious answer here... I am left confused with this one:
Why do I get 17.8 MiB heap memory allocated when all I have done is:
If I take out the android:background="@drawable/background4"
line, the allocated memory goes down to 11.9 MiB.
I also ran a MAT report on it, but I am not sure what conclusion to draw from it:
Thanks in advance,
And added a 56 KiB background image.
No, you added a 56 KiB file that you are using as a background image.
The actual heap space consumed by a bitmap is three bytes per pixel. With a ~6MB bitmap (per your MAT screen), you are running your app on a fairly high resolution device or emulator (1080p should result in ~8MB, IIRC).
AFAIK Android will convert the image in your layout to byte Array when it inflate your layout.
It needs background image to expand to fit into your screen, doing that takes extra memory..so that 's why it allocate that much memory. I may not be right but let me know if I am wrong.
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