Search code examples
androidandroid-bitmapandroid-memory

Why are hundreds of bitmaps in memory for a basic android app?


When building my first Android app I noticed that memory usage was already approaching 20MB right when the app started. I downloaded the Eclipse MAT and viewed the contents to find hundreds, if not thousands, of bitmaps in memory. Many of which are not used directly in my project (at least not so much that I would be aware)

Largest Image is 9MB: https://imagebin.ca/v/2eCK4JYLO2f2

Others are much smaller: https://imagebin.ca/v/2eCMmbFuIWsz

Android seems to have gone to great lengths to reduce memory by using the zygote... so why are there so many unused bitmaps already in memory?

(Basic project is a blank activity using Android Studio with fragment made up of a text view which simply says "Hello World!")


Solution

  • I have found that the bitmaps are from the Zygote's memory footprint. Since all java-based apps are started via the zygote this means that the minimal memory usage is determined by the size of memory in use by the Zygote which in turn is based on the display density of the device.

    Answers found:
    Find the class that wastes memory
    Locate & remedy cause of large heap size