• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There are 3 highly popular myths about Garbage Collection. Let’s review those myths and the actual truth behind them.

Myth #1: Minor GC don’t pause the application
There are different types of Garbage Collection events: Minor GC event, Major GC event & Full GC event. It’s been educated that Minor GC are harmless, as they don’t pause the application. However Major/Full GC are dangerous because it pauses the application.

This is a lie. 100% lie. Minor GC *do pause* the application. Minor GC pause times are comparatively lower than other GC events most of the times. Thus, it could have been educated as ‘harmless’. However, in some cases, we have seen Minor GC take more time than all the Major/Full GC events. Thus, when tuning your application, pay proper attention towards Minor GC pause time Metrics as well.

Myth #2: Serial GC performance is horrible
There are several types of Garbage Collection algorithms:

1. Serial GC
2. Parallel GC
3. Concurrent Mark & Sweep (CMS) GC
4. G1 GC
5. Shenandoah GC

Each GC algorithm exhibits its unique performance characteristics. A false education industry has been making: ‘Serial GCs are not meant for serious applications.’ Serial GC performance characteristics are horrible. It should be used only during development time or in prototype applications.

To validate this theory, we conducted a study on a major B2B travel application in production, which processes more than 70% of North America’s leisure travel transactions. We configured a couple of servers to use latest ‘G1 GC’ algorithm and couple of servers to use ‘Serial GC’ algorithm. We just used vanilla G1 GC and Vanilla Serial GC settings. We didn’t pass any additional GC tuning parameters. Details about this study can be found here.

Results turned out that Serial GC performance to be comparable (in fact slightly better than) to G1 GC algorithm. Of course, with proper tuning & parameters settings, G1 GC can be made to run better than Serial GC. The take away is, Serial GC is not as bad as it’s portraited.

Myth #3: Garbage Collection is automatic. I don’t have to worry about it.
I have heard few developer friends saying: “Garbage Collection is Automatic. I don’t have to worry about it”.

First part is true, i.e. “Garbage Collection is Automatic” on all modern platforms – JVM (Java Virtual Machine), ART (Android Run Time)… But the second part is not so true, i.e. “I don’t have to worry about it”. Garbage Collection is automatic, but it’s not free. It comes with a price. In fact, the price can be *very expensive*. Poor Garbage Collection can lead to:

+ Unpleasant user experience (SLA Breaches)

+ Increase in the bill from cloud hosting providers

+ Puts entire application availability under risk

To learn about the profound impact of Garbage Collection, you may consider reading this article.

Your buns are mine! But you can have this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!