Memory utilization on the mobile app has a significant impact on the customer experience. If your app creates a lot of objects, then Garbage Collection (GC) process will be triggered frequently to evict unused objects. Even though Garbage Collection is an automatic process, however, frequent Garbage Collection consumes a lot of CPU + it will also pause the app. Frequent pauses can jank the app (i.e. stuttering, juddering, or halting).

Thus, you need to understand how many objects your app is creating, how frequently Garbage collection is triggered, how much time it takes to complete, how much memory is reclaimed after every event. All this information is present in the runtime log messages. Whenever a GC event runs, a log line is printed in the runtime log messages. You can view those log lines through logcat.

GC log line format varies based on whether app runs on Dalvik VM or Android Run Time (ART). In the earlier article, we saw how to analyze ART GC log line. In this article, let’s see how to analyze Dalvik GC log line.

This is how a typical Dalvik GC log line will look like:

Dalvik-1

This one single log line has multiple fields. Below table summarizes each field in detail:

 

#

Field Value Description
1 Timestamp 07-01 15:56:19.815 Timestamp at which this Garbage Collection event ran
2 GC Reason GC CONCURRENT Reason why Garbage Collection event was triggered. Please refer here for different types of GC Reasons.
3 Objects freed 7078K Amount of objects garbage collected. Totally 7078kb of objects are garbage collected (i.e. freed) in this event.
4 Heap usage 52464K/ 89052K 52464kb of objects are alive after this particular GC event. Total allocated heap size for this app is 89052 kb.
5 GC Pause Time 14ms+4ms During certain phases of GC event, application is paused. In this GC event, pause time is 18 ms (i.e. 14 + 4 ms). During pause time, application freezes. One should target for low pause time.
6 GC Total Time 96ms Amount of time this GC event took to complete. It includes the GC Pause time as well.

Tools

Dalvik-3

Fig 1: Android memory usage – report generated by GCeasy.io

Dalvik-2

Fig 2: KPI – report generated by GCeasy.io

As it might get tedious to analyze every single GC log line, you can also consider using free online tools such as GCeasy.io – a universal Garbage collection log analyzer, to analyze Android GC logs. You can just upload the Android GC Logs to this tool. Tool parses GC log and generates report instantly. Report contains interactive graphs and insightful metrics. A Few excerpts from this report are given above for your reference.