Search code examples
androidgarbage-collectionheap-memoryeclipse-memory-analyzer

17.8 MiB heap allocation for a simple "Hello World" project?


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:

  1. Created a simple "Hello World" project with Eclipse's New Project option.
  2. And added a 56 KiB background image.

If I take out the android:background="@drawable/background4" line, the allocated memory goes down to 11.9 MiB.

  • Is this normal for the system to allocate this much memory? Should I worry about it?
  • What would take up this much of the heap?

I also ran a MAT report on it, but I am not sure what conclusion to draw from it:

Thanks in advance,


Solution

  • 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).