Android Studio Profiler shows 100 MB of memory usage for empty activity

1.8k Views Asked by At

I'm using Android Studio Profiler to check and optimize memory consumption. to do some tests, I have disabled every section in the app except for the main activity. so when the app launches, there is only a blank activity which does not do anything and does not hold any view. then when I run the profiler, it shows about 100 MB of memory is being used by my app, half of which is for native code.

Moreover, when I dump the heap, it shows only 6.3 MB of retained size. these numbers confuse me! how and why such large amounts of memory (100 MB) are being used while my activity is empty and not doing any task?

enter image description here enter image description here

1

There are 1 best solutions below

0
On

The screenshot shows the app heap is about 6.3 MB. There may be other heaps (clicking the "View app heap" menu). Those heaps combined are what the JVM is using, which should be consistent with the "Java" category from the profiler's timeline.

To find out what native memory is used for, it may be helpful to try Android Studio's native memory profiler during app startup.

When the profiler is used with a debuggable process, it will do things behind the scene, such as attaching a JVMTI agent. Those operations will occupy native memory. To eliminate those noise, please consider using a profileable build. Here is the instruction to build a profileable app, and you need Android Studio Bumblebee to view profileable processes in the profiler.