Androidcoder Androidcoder -5 years ago 173
Android Question

Why is Samsung Galaxy S6 (Lollipop) allocating 4 times the memory of older devices for bitmaps

I just started testing my game app on a new Samsung Galaxy S6. It kept crashing with out of memory errors in the log. My app normally uses about 215M and worked fine with the Galaxy S4 mini, Galaxy Tab S3, and Galaxy Tab S4, which have heaps of 256+M, 512+M and 512+M respectively. The Galaxy S6 has a heap of 536M. After cutting down my bitmap sizes to where I could get the Galaxy S6 to run the app, I got the following on the device monitor for heap use of the various devices.

Galaxy S4 mini, Galaxy Tab S3, and Galaxy Tab S4:
enter image description here

Galaxy S6 (Lollipop):
enter image description here

Why does the newer device use 4 times the heap of the other devices?

Answer Source

It turns out the issue was something being done on the device end, not mentioned in the documentation on supporting different screen sizes here: According to an insightful article by Gokhan Arik, 'Android background image high memory usage issue' at, referencing a CommonsWare answer to a question similar to mine here: Why does my 160kb app background become 49 MB at run time?, high density devices will resize images stored in a generic 'drawable' folder to a much greater size to match the higher screen resolution, by 4x in my case.

The simple solution was to put all my bitmaps (many several hundred KB in size) into a folder named 'drawable-nodpi', and deleting the old 'drawable' folder. I wish I knew about this issue before I could finally afford a density 3 device to test on.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download