From Java 5 onwards an improvement is made in Java by selecting the Garbage Collector (GC)
based on the class of the machine on which the application is run.
The serial collector uses a single thread to perform all garbage collection work, which makes it relatively efficient since there is no communication overhead between threads. Suited for single processor servers.
Known as the throughput collector performs minor collections in parallel, which can significantly reduce garbage collection overhead.Suited for medium- to large-sized data sets that are run on multiprocessor or multi-threaded hardware.
New: parallel compaction is a feature introduced in J2SE 5.0 update 6 and enhanced in Java SE 6 that allows the parallel collector to perform major collections in parallel. Without parallel compaction, major collections are performed using a single thread, which can significantly limit scalability. Parallel compaction is enabled by adding the option
-XX:+UseParallelOldGCto the command line.
Performs most of its work concurrently (i.e., while the application is still running) to keep garbage collection pauses short.For medium- to large-sized data sets for which response time is more important than overall throughput
If the application has a small data set (up to approximately 100MB), then
If the application will be run on a single processor and there are no pause time requirements
If (a) peak application performance is the first priority and (b) there are no pause time requirements or pauses of one second or longer are acceptable,
If response time is more important than overall throughput and garbage collection pauses must be kept shorter than approximately one second