Monday, February 10, 2014

Serial v/s Parallel GC




Note: For GC basics, refer following post

Serial GC (default):
Minor and major garbage collections are done serially.
It moves older memory to the beginning of the heap so that new memory allocations are made into a single continuous chunk of
memory at the end of the heap. This compacting of memory makes it faster to allocate new chunks of memory to the heap.

-XX:+UseSerialGC

Parallel GC:
It uses multiple threads to perform the young genertion garbage collection.
If your host has X CPUs, it will use X threads by default.
One can also set the # of threads by command line using:

-XX:ParallelGCThreads=<# of threads>

Note:
On a host with a single CPU the serial (default) garbage collector is used even if the parallel garbage collector has been requested.
If you want multi-thread young generation collector with a single-threaded old generation collector, use:
-XX:+UseParallelGC

If you want both a multi-threaded young generation collector and multi-threaded old generation collector, use:
-XX:+UseParallelOldGC

G1 (Garbage First) Garbage collector:

The G1 (Garbage First) garbage collector is available from Java 7.
It has a parallel, concurrent and multi-phased marking cycle, and can work with much larger heaps.

Usage: -XX:+UseG1GC

Will dwell more on this in a subsequent post.

Note: For GC basics, refer following post

No comments:

Post a Comment