DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Memory Management in Android
  • All You Need To Know About Garbage Collection in Java
  • Java Memory Management
  • 5 Top Programming Languages For Your Android App Development Project

Trending

  • Understanding Git
  • How To Start a Successful Career in DevOps
  • Running Unit Tests in GitHub Actions
  • How To Learn Secure Software Development Lifecycle (SDLC)
  1. DZone
  2. Coding
  3. Languages
  4. Understanding Android Garbage Collection Logs

Understanding Android Garbage Collection Logs

If your app creates a lot of objects, then the Android run time (ART) environment will trigger garbage collection (GC) frequently. Here's how to deal with it.

Ram Lakshmanan user avatar by
Ram Lakshmanan
CORE ·
May. 12, 17 · Opinion
Like (3)
Save
Tweet
Share
26.29K Views

Join the DZone community and get the full member experience.

Join For Free

Memory utilization on the mobile app has a significant impact on customer experience. If your app creates a lot of objects, then the Android run time (ART) environment will trigger garbage collection (GC) frequently. Android garbage collection is an automatic process which removes unused objects from memory. However, frequent garbage collection consumes a lot of CPU, and 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, 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.

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

07-01 16:00:44.690: I/art(801): Explicit concurrent mark sweep GC freed 65595(3MB) AllocSpace objects, 9(4MB) LOS objects, 34% free, 38MB/58MB, paused 1.195ms total 87.219ms

This one single log line has multiple fields. Let’s review them:

Image title

# Field Value Description
1 Timestamp 07-01 16:00:44.690 Timestamp at which this garbage collection event ran.
2 GC Reason Explicit Reason why garbage collection event was triggered. ‘Explicit’ indicates that garbage collection was explicitly requested by an app, for example, by calling gc() or gc(). Please refer here for different types of GC Reasons.
3 GC Name concurrent mark sweep ART has various different GCs which can get run. In this case, ‘Concurrent Mark Sweep’ indicates – a whole heap collector which frees collects all spaces other than the image space.  Please refer here for different types of GC Names.
4 Objects freed 65595(3MB) Amount of objects garbage collected from non-large objects space. Totally 65595 unique objects, whose cumulative size of 3mb is garbage collected (i.e. freed) in this event.
5 Large objects freed 9(4MB) Amount of objects garbage collected from Large objects space. Totally 9 unique objects, whose cumulative size of 4mb is garbage collected (i.e. freed)
6 Heap usage 38MB/58MB 38mb of objects is alive after this particular GC event. Total allocated heap size for this application is 58mb.
7 GC Pause Time 1.195ms During certain phases of GC event, the application is paused. In this GC event, pause time is 1.195ms. During pause time, application freezes. One should target for low pause time.
8 GC Total Time 87.219ms Amount of time this GC event took to complete. It includes the GC Pause time as well.

Tools

Image title

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

Image title

 Figure 2: Android GC Statistics — 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. The tool parses GC log and generates reports instantly. The report contains interactive graphs and insightful metrics. A few excerpts from this report were given above for your reference.

garbage collection Garbage (computer science) Android (robot) mobile app Object (computer science) Event

Opinions expressed by DZone contributors are their own.

Related

  • Memory Management in Android
  • All You Need To Know About Garbage Collection in Java
  • Java Memory Management
  • 5 Top Programming Languages For Your Android App Development Project

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: