Solved

Java Gargabe Collector type

Posted on 2015-01-05
1
217 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 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Fine Tune your automatic Updates for Ubuntu / Debian
This video teaches viewers about errors in exception handling.
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.

691 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