Does your Application stall for several seconds (or more)?

Garbage Collection

If you have a Java app that handles large volumes of data but your app hangs randomly for several seconds (or even minutes), a good call will be a wrong configuration of Java's Garbage Collection. What can be done?

First of all lets get some of the garbage collector's logs.
In order to see the GC's logging (Stdout) details, use these command line parameters:

  • -verbose:gc
  • -XX:+PrintGCDetails
  • -XX:+PrintGCTimeStamps

Eg: java -jar -verbose:gc -XX:+PrintGCTimeStamps java_app.jar


Now to the actual garbage collecting.
Apparently Java 1.5 has three different fixed garbage collection modes.

The fixed garbage collection modes are:

  • -XX:+UseConcMarkSweepGC
  • -XX:+UseParallelGC
    • -XX:ParallelGCThreads=
  • -XX:+UseTrainGC

Eg: java -jar -verbose:gc -XX:+PrintGCTimeStamps -XX:+UseParallelGC java_app.jar


If you find the fixed garbage collection modes not satisfying enough, you can configure the garbage collector manually with several additional command line parameters, use the second link at the bottom of the page for more details.


I strongly recommend the following links that refer to Java's garbage collector:

Introduction to Java's garbage collector

FineTuning Java's Garbage Collector

Comments

Popular posts from this blog

Profiling Java @ 2019

Ant Explorer graphical Ant build tool

Start Working with AutoIT