Garbage Collection Recommendations

  • Use G1GC (-XX:+UseG1GC)

    G1GC is the default garbage collection algorithm for JDK 9 and later.

    In production TIBCO OPE holds a large amount of model data and related business objects in memory. Due to the generation of large request and response objects, applications may warrant a large amount of garbage collection.

    TIBCO OPE recommends you use G1GC as this divides the heap into a set of regions. Most GC operations can then be performed a region at a time rather than on the entire Java heap or an entire generation thus improving the garbage collection process.

  • Set Total Heap (-Xms, -Xmx)

    The important factor affecting garbage collection performance is total available memory. Because collections occur when generations fill up, throughput is inversely proportional to the amount of memory available

    TIBCO OPE recommends using same value for Xms and Xmx flags

  • Setting Young Generation Sizing (-XX:NewRatio or -XX:NewSize and -XX:MaxNewSize)

    After total available memory, the second most influential factor affecting garbage collection performance is the proportion of the heap dedicated to the young generation.

    The value of the young generation should be at least a third of the total size of the heap i.e. ratio of young generation to the old generation should be at least 1:3. If performance tests show too many minor GCs, this size can be increased further.

  • String Deduplication (-XX:+UseStringDeduplication)

    Strings consume a lot of memory in any application. With Oracle Java 8 Update 20, G1 introduced a string deduplication feature where a hashcode of a string is stored along with a weak reference to its character array. When it finds another string with the same hashcode, one string is modified to point to the char array of the second string.

    OPE recommends you use this flag.

  • Maximum Garbage Collection pause time (-XX:MaxGCPauseMillis)

    MaxGCPauseMillis sets a target for the maximum GC pause time.

    TIBCO OPE recommends you use this flag.

    Note: A very low value for this flag inversely affects throughput.
  • Number of threads for parallel and concurrent garbage collection (-XX:ParallelGCThreads, -XX:ConcGCThreads)

    ParallelGCThreads sets the number of threads used during parallel phases of the garbage collectors and ConcGCThreads sets the number of threads used for concurrent garbage collection. For both, the default value varies with the platform on which the JVM is running.

  • Other Garbage Collection flags

    • Print all Garbage Collection logs in a separate log file

      -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime

      -XX:+PrintGCApplicationConcurrentTime -XX:+PrintAdaptiveSizePolicy

      -XX:+PrintTenuringDistribution -XX:+PrintGCTimeStamps

      -XX:+PrintGCDateStamps

    • Print heap dump

      -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath

    • Rolling Garbage Collection logs

      -Xloggc -XX:+UseGCLogFileRotation -XX:GCLogFileSize

  • Minimal Kernel Time

    Garbage Collection pauses are affected by kernel CPU utilization time. Garbage Collection logs display information about kernel time along with user time (application Garbage Collection time). High amounts of kernel time can cause longer Garbage Collection pauses as application JVM competes with other application(s) running on the same host for the core computing resources.

    As part of production deployment, Garbage Collection needs to make sure that the host machine is not running too many resource intensive applications along with TIBCO OPE.