问题
I have a very simple android application with a single activity which has only 1 TextView which says "Hello World". The app doesn't doesn't do anything else. Its the default app you get when you create a new app in Android Studio. Basically the app doesn't do anything.
As expected, when you try to do memory analysis for this app, the Android Device Monitor shows a very small memory usage (heap size ~ 10 MB, heap allocation ~ 3 MB) on hdpi/mdpi devices like MotoE, MotoG etc.
However on xhdpi/xxhdpi devices (Nexus 5, Xiaomi Mi3, Mi4i, Samsung Galaxy Note 2 etc) the app heap size suddenly shoots to 31 MB and allocation to 23 MB.
Here is a screen shot from the Android Device Monitor for Xiaomi Mi3:

I took a heap dump and opened it in the memory analyzer tool (MAT). The 2 main leak suspects were classes "android.content.res.Resources" and "android.graphics.NinePatch", with an allocation of 20.3 MB just for the 2 of them.
The class "android.content.res.Resources", loaded by "<system class
loader>", occupies 87,24,208 (36.45%) bytes. The memory is accumulated
in one instance of "android.util.LongSparseArray[]" loaded by "<system
class loader>".
217 instances of "android.graphics.NinePatch", loaded by "<system
class loader>" occupy 1,26,11,616 (52.70%) bytes. These instances are
referenced from one instance of "java.lang.Object[]", loaded by "
<system class loader>"
There was also a hint which said that the two suspects may be related, because the reference chains to them have a common beginning.
Why is such a large amount of heap memory allocated to these 2 classes for such a simple application, which basically does nothing?
来源:https://stackoverflow.com/questions/30980112/high-ram-usage-for-empty-android-application