androidperformanceandroid-profiler

Android Profiler timeline vs heap dump values


I created a sample app and ran the Android Profiler. Just before getting a Java/Kotlin memory dump, I saw these numbers:

enter image description here

However, in the memory dump window I see these:

View App Heap enter image description here

View All Heaps enter image description here

Let's take a look at the numbers: Native equals to 4.6 MB before the dump, and in the dump I see the native size equals to 92,041 or 91 kB (app heap) and 505,895 or 505 kB (all heaps). Neither of them is close to 4.6 MB. So I wonder how the graph numbers and the numbers in the heap dump are related.

Similarly, I don't understand how the retained size values from the dump are related to Others, Code, Stack, Graphics and Java in the timeline.


Solution

  • Here is my assumption. The Memory Overview article says:

    When inspecting your app's heap, Android computes a value called the Proportional Set Size (PSS), which accounts for both dirty and clean pages that are shared with other processes—but only in an amount that's proportional to how many apps share that RAM

    and the explanation of how memory is counted contains:

    The numbers you see at the top of the Memory Profiler (figure 2) are based on all the private memory pages that your app has committed, according to the Android system. This count does not include pages shared with the system or other apps.

    So the app heap value of 8,372,986 (or ~8.3 MB) I saw included both dirty and clean pages that are shared with other processes whereas 5.4 MB of Java memory from the first screenshot includes private memory pages that my app has committed, according to the Android system. This count does not include pages shared with the system or other apps.