Saturday, 23 April 2016

What are different types of Garbage collector in Java ?

Types of Garbage Collector in Java
Java Runtime provides various types of Garbage collection in Java which you can choose based upon your application's performance requirement.
Java 5 adds three additional garbage collectors except serial garbage collector.

1) Throughput Garbage Collector
It uses a parallel version of the young generation collector.
JVM argument to use -XX:+UseParallelGC 
The tenured generation collector is same as the serial collector.

2) Concurrent low pause Collector
This is also referred as Concurrent Mark Sweep Garbage collector.
It is used to collect the tenured generation and does most of the collection concurrently with the execution of the application. The application is paused for short periods during the collection. A parallel version of the young generation copying collector is sued with the concurrent collector.
JVM arguments to use -Xingc or -XX:+UseConcMarkSweepGC

Concurrent Mark Sweep Garbage collector is most widely used garbage collector in java and it uses algorithm to first mark object which needs to collected when garbage collection triggers.

3) The Incremental (train) low pause collector
This garbage collector has not changed since the java 1.4.2 and is currently not under active development. It will not be supported in future releases so avoid using this and please see 1.4.2 GC Tuning document for information on this collector.
JVM argumets to use -XX:+UseTrainGC

Note : -XX:+UseParallelGC should not be used with -XX:+UseConcMarkSweepGC.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.