Out of curiosity, I just recently tested my Android App for Memory Leaks, using the Eclipse Memory Analyzer.
I came across a strange Bitmap with the size of 512 x 512 pixels using up about 1 Megabyte of my devices heap memory.
I checked my drawables folder and could not find a bitmap of that size (512 x 512).
I started googling and came across this question, where a user explains how to get the actual Image behind a "memory leak" reference in the Memory Analyzer:
MAT (Eclipse Memory Analyzer) - how to view bitmaps from memory dump
I followed the tutorial and with the help of GIMP, I extracted the following Image:
So my questions are:
Notes:
Update:
With the help of Selvin's suggestion and my personal felling that this could be a System-issue, I tested two other apps of mine.
Both of the apps I tested also showed the same Bitmap in the Memory Analyzer with exactly the same amount of bytes consumed:
Furthermore, I was able to find out that:
The source of the Bitmap is always associated with the LAUNCHER Activity of the app.
So what to do about that? Is there a way to get rid of it?
Since I do memory-intensive operations in my app, I'd like to have as much heap available as possible.
The default window background used by Android is a 512x512 image (the blueish-dark gradient you see with the dark theme or the gray-white gradient with the light theme). On capable devices, this image is replaced with a procedural gradient as of Android 4.2.
Note that this bitmap is normally loaded in Zygote and shared by all the apps. It might show up in heap dumps if the dump doesn't exclude Zygote-allocated objects.
Here are the two 512x512 backgrounds I'm talking about if you're interested:
https://github.com/android/platform_frameworks_base/blob/jb-mr0-release/core/res/res/drawable-nodpi/background_holo_dark.png
https://github.com/android/platform_frameworks_base/blob/jb-mr0-release/core/res/res/drawable-nodpi/background_holo_light.png
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