2

My question is essentially this:

How on earth can a 17kb png file cause the memory to spike to 60MB?

I noticed the UI was extremely sluggish whenever a particular image was on-screen.

I have narrowed my problem to be a *.PNG file I am using. It is only 17kb. https://i.stack.imgur.com/c2rzO.jpg

In Memory Monitor the memory usage was at a WHOPPING 60MB.

My android 2.3 emulator sat at around 3MB, whereas my phone goes up to 60MB and my nexus 6 (5.0.1) emulator force closes due to "java.lang.OutOfMemory" error.

XdrummerXboy
  • 142
  • 1
  • 11

1 Answers1

4

Simple PNGs compress very well, so the file size may be misleading.

This bitmap has 1400x1400 pixels. So it's 7.8MB when unpacked to a bitmap. Nexus uses hardware acceleration. It may buffer this image with 2048x2048px texture which is another 16.8MB (maybe less with compression).

Nexus 6 has very dense screen and may scale the image while loading - that may be another cause.

Zielony
  • 16,239
  • 6
  • 34
  • 39
  • Ahh, I didn't realize there was unpacking and such. Thank you! I also came across this post about it: http://stackoverflow.com/questions/13118005/android-background-image-memory-usage – XdrummerXboy Jan 15 '15 at 12:40