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

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

Full-Stack Observability Essentials: Explore the fundamentals of system-wide observability and key components of the OpenTelemetry standard.

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

  • How Java Apps Litter Beyond the Heap
  • All You Need To Know About Garbage Collection in Java
  • Java Memory Management
  • Garbage Collection in Java (JVM)

Trending

  • CI/CD Tools and Technologies: Unlock the Power of DevOps
  • Setting up Request Rate Limiting With NGINX Ingress
  • Log Analysis: How to Digest 15 Billion Logs Per Day and Keep Big Queries Within 1 Second
  • Revolutionizing Software Testing
  1. DZone
  2. Coding
  3. Languages
  4. Java Garbage Collection Algorithm Design Choices And Metrics To Evaluate Garbage Collector Performance

Java Garbage Collection Algorithm Design Choices And Metrics To Evaluate Garbage Collector Performance

Singaram Subramanian user avatar by
Singaram Subramanian
·
Jan. 19, 12 · Interview
Like (0)
Save
Tweet
Share
13.54K Views

Join the DZone community and get the full member experience.

Join For Free

 

Memory Management in the Java HotSpot Virtual Machine

 

View more documents from white paper

Serial vs Parallel

With serial collection, only one thing happens at a time. For example, even when multiple CPUs are available, only one is utilized to perform the collection.

When parallel collection is used, the task of garbage collection

is split into parts and those subparts are executed simultaneously, on different CPUs.

 

The simultaneous operation enables the collection to be done more quickly, at the expense of some additional complexity and potential fragmentation.

Concurrent versus Stop-the-world

When stop-the-world garbage collection is performed, execution of the application is completely suspended during the collection. Alternatively, one or more garbage collection tasks can be executed concurrently, that is, simultaneously, with the application.

Typically, a concurrent garbage collector does most of its work concurrently, but may also occasionally have to do a few short stop-the-world pauses.

Stop-the-world garbage collection is simpler than concurrent collection, since the heap is frozen and objects are not changing during the collection. Its disadvantage is that it may be undesirable for some applications to be paused.

Correspondingly, the pause times are shorter when garbage collection is done concurrently, but the collector must take extra care, as it is operating over objects that might be updated at the same time by the application.

This adds some overhead to concurrent collectors that affects performance and requires a larger heap size.

Compacting versus Non-compacting versus Copying

After a garbage collector has determined which objects in memory are live and which are garbage, it can compact the memory, moving all the live objects together and completely reclaiming the remaining memory.

After compaction, it is easy and fast to allocate a new object at the first free location. A simple pointer can be utilized to keep track of the next location available for object allocation.

In contrast with a compacting collector, a non-compacting collector releases the space utilized by garbage objects in-place, i.e., it does not move all live objects to create a large reclaimed region in the same way a compacting collector does.

The benefit is faster completion of garbage collection, but the drawback is potential fragmentation. In general, it is more expensive to allocate from a heap with in-place deallocation than from a compacted heap.

It may be necessary to search the heap for a contiguous area of memory sufficiently large to accommodate the new object.

A third alternative is a copying collector, which copies (or evacuates) live objects to a different memory area. The benefit is that the source area can then be considered empty and available for fast and easy subsequent allocations, but the drawback is the additional time required for copying and the extra space that may be required.

Performance Metrics

Several metrics are utilized to evaluate garbage collector performance, including:

  • Throughput—the percentage of total time not spent in garbage collection, considered over long periods of time.
  • Garbage collection overhead—the inverse of throughput, that is, the percentage of total time spent in garbage collection.
  • Pause time—the length of time during which application execution is stopped while garbage collection is occurring.
  • Frequency of collection—how often collection occurs, relative to application execution.
  • Footprint—a measure of size, such as heap size.
  • Promptness—the time between when an object becomes garbage and when the memory becomes available.
If you’d like to explore more on this and in general about Java’s garbage collection / memory management, have a look at these slides:
Java Garbage Collection, Monitoring, and Tuning

 

View more presentations from Carol McDonald

 

Related articles
  • Practical Garbage Collection – Part 1: Introduction (worldmodscode.wordpress.com)
  • Reducing memory churn when processing large data set (stackoverflow.com)
  • The Top Java Memory Problems – Part 2 (dynatrace.com)
  • imabonehead: Performance Tuning the JVM for Running Apache Tomcat | TomcatExpert (tomcatexpert.com)
  • When Does the Garbage Collector Run in JVM ? (javacircles.wordpress.com)
  • Why Garbage Collection Paranoia is Still (sometimes) Justified (prog21.dadgum.com)
  • Adventures in Java Garbage Collection Tuning (rapleaf.com)

 

From http://singztechmusings.in/java-garbage-collection-algorithm-design-choices-and-metrics-to-evaluate-garbage-collector-performance/

garbage collection Garbage (computer science) Java (programming language) Algorithm design

Opinions expressed by DZone contributors are their own.

Related

  • How Java Apps Litter Beyond the Heap
  • All You Need To Know About Garbage Collection in Java
  • Java Memory Management
  • Garbage Collection in Java (JVM)

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: