Solved

Java Gargabe Collector type

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux Filesystems reporting faster growth than actual file growth... 7 57
cannot rename datastore 3 45
Desingning Refactoring existing code 2 24
maybe no no httpd.conf 6 45
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ā€¦
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will giveā€¦
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

813 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

17 Experts available now in Live!

Get 1:1 Help Now