Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Android Dalvik GC Log Analysis

DZone's Guide to

Android Dalvik GC Log Analysis

Your mobile app's memory usage impacts the user experience. Gain a better understanding of how memory usage is logged and what it can tell you.

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Memory utilization on a mobile app has a significant impact on the customer experience. If your app creates a lot of objects, then the 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, and it will also pause the app. Frequent pauses can mess up the app (e.g. stuttering 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, and 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 an earlier article, we saw how to analyze ART GC log lines. Now let’s see how to analyze a Dalvik GC log line.

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

Image title

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

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 below for your reference.

Image title

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

Image title

Fig 2: KPI – report generated by GCeasy.io.

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:
android ,mobile ,mobile apps ,mobile app development

Published at DZone with permission of Ram Lakshmanan. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}