Friday, January 20, 2012

Garbage Collection and JAVA

Introduction :
Garbage collection is an amazing feature of java. Application developer use java for different kind of application ranging form small to complex enterprise software application. So demand of garbage collection is different based on nature of java application. Java HotSpot™ virtual machine implementation (Java HotSpot™ VM) provides multiple garbage collectors, each designed to satisfy different requirements.

Question is when the choice of garbage collector is a big issue . Most of the case it is not too important. But in case of large application its tightly related to performance issue.

Performance issue of java powered application is tightly related to the proper combination of three parameter namely :

  • garbage collector,
  • heap size,
  • and runtime compiler

Available Garbage Collector :
Java HotSpot VM includes three different collectors, each with different performance characteristics.

  1. The serial collector
  2. The parallel collector
  3. The concurrent collector
Selecting a Garbage Collector :
1. If the application has a small data set (up to approximately 100MB), then serial collector is ok: and we can select it as by : -XX:+UseSerialGC. If the application will be run on a single processor and there are no pause time requirements, then
    • let the VM select the collector, or
    • select the serial collector with -XX:+UseSerialGC.
  1. 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, then
    • let the VM select the collector, or
    • select the parallel collector with -XX:+UseParallelGC and (optionally) enable parallel compaction with -XX:+UseParallelOldGC.
  2. If response time is more important than overall throughput and garbage collection pauses must be kept shorter than approximately one second, then
    • select the concurrent collector with -XX:+UseConcMarkSweepGC. If only one or two processors are available, consider using incremental mode, described below.

No comments:

Post a Comment