Solved

Java Gargabe Collector type

Posted on 2015-01-05
1
211 Views
Last Modified: 2015-01-09
Given the following Java contained on Red hat 6.x

java -XX:+PrintCommandLineFlags -version
-XX:InitialHeapSize=2147483648 -XX:MaxHeapSize=32037767584 -XX:+PrintCommandLineFlags -XX:+UseCompressedOops -XX:+UseParallelGC
java version "1.7.0_71"
OpenJDK Runtime Environment (rhel-2.5.3.1.el6-x86_64 u71-b14)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

Open in new window


So this version is using Parallel GC by default.

What exactly is Parallel GC (other than a multi-threaded GC)  compared to the other types of GC?

Thanks
0
Comment
Question by:Anthony Lucia
1 Comment
 
LVL 26

Accepted Solution

by:
dpearson earned 500 total points
ID: 40532084
The classic - single threaded - Java GC works by a "stop the world" model.  This means when the GC needs to run, it stops all threads, figures out all the garbage in the system, removes it - repacking memory down, and then restarts the threads.

This works well in relatively small memory systems (e.g. 1GB or less) but as memory has risen to 32GB or 64GB systems it creates a problem because this "GC pause" gets longer and longer.  You can easily see systems waiting for 2 or 3 seconds while GC happens - which may become noticeable to users.

So the folks at Sun (Oracle) have been working on replacements.  These other algorithms are all multi-threaded and the basic idea is to try to reduce those pauses.  So they try to determine where the garbage is and clean up that garbage without having to stop all threads as much.  They still all involve some sort of pauses, but hopefully shorter ones.

The algorithms themselves can be quite complex and are interesting to delve into, but the basic idea isn't hard to grasp that you could use background threads to do some of the work.

However, the main thing to be aware of if you're running a system using one of the parallel collectors is that it involves a trade-off.  These collectors are designed so that the background threads clean up garbage more rapidly than new garbage is created.  If that assumption fails (you are creating lots of new garbage objects, there's too little CPU time assigned to the background threads etc.) then they can be required to do a "stop the world" garbage collection and that collection can be catastrophically bad - as in it could take 30 secs on a large RAM machine.

So if you see very occasional but very long pauses, this could be the cause.  Something to monitor for.
You can also turn on logging for the GC and see exactly what it's doing, how long it's pausing etc:
https://blog.codecentric.de/en/2014/01/useful-jvm-flags-part-8-gc-logging/

Doug
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now