?
Solved

Java Gargabe Collector type

Posted on 2015-01-05
1
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 28

Accepted Solution

by:
dpearson earned 2000 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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Fine Tune your automatic Updates for Ubuntu / Debian
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month9 days, 20 hours left to enroll

762 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