Jump to content
We've recently updated our Privacy Statement, available here ×
  • Sun OpenJDK JVM Garbage Collection Tuning


    djohnson53
    • Version: v5.1 Product: JasperReports® Server

    Introduction

    This tutorial covers basic performance diagnostic and tuning techniques for Sun and OpenJDK JVM garbage collection. The tutorial focuses on basic memory problems and command line settings for improving garbage collection performance when running JasperReports Server.

    Objectives

    This guide will enable you to:

    Pre-Requisites

    • Basic administration of common J2EE web or application servers ( Tomcat, JBoss, GlassFish )
    • Required permissions to shutdown and restart the server and edit config files
    • Java 5.0 or later

    Assumption: Use of bundled Tomcat included with JasperReports Server

    Diagnosing Memory Problems

    Steps for diagnosing memory problems and monitoring memory usage:

    • Launch JConsole
    • Ask users to use JasperReports Server or simulate load with QA tool
    • Watch memory usage
    Step Action
    1

    Open the file /apache-tomcat/bin/setenv.bat

    2

    Add the following JVM options to the JAVA_OPTS variable:

    • Dcom.sun.management.jmxremote
    • Dcom.sun.management.jmxremote.port=9004
    • com.sun.management.jmxremote.authenticate=false
    • Dcom.sun.management.jmxremote.ssl=false
    • verbose:gc
    • XX:+PrintGCDetails
    • XX:+PrintGCTimeStamps
    • XX:-TraceClassUnloading
    • Xloggc:"apache-tomcatwebappsjasperserver-proWEB_INFlogsgc.log"
    3 Restart JasperReports Server
    4 Launch the /bin/JConsole.exe application
    5 Click the Remote tab and enter the following values:
    • Host or ip: (localhost if running locally)
    • Port: 9004
    • Username and Password:
    6 Click the Memory tab
    7 Either have users use JasperReports Server or use a load testing tool (such as LoadRunner) to simulate peak load conditions.
    8

    Observe the memory usage characteristics. Normal usage will look like this:

    graph1.jpg.81fed7ee436ced85e80f3ccc1a124409.jpg

    Whereas a situation where garbage collection is inadequate or nonexistent will look like this:

    garbagecollection2.jpg.9a05328848a8214d116478bb85a556a7.jpg

    If the “valleys” of the memory usage graph don’t return to a baseline and memory usage is increasing over time, then there is either a memory leak or garbage collection problem.

    9 Open the apache-tomcatwebappsjasperserver-proWEB-INFlogsgc.log file
    10 Look for messages that start with GC failed
    11

    If garbage collection failures occur right before system crashes, it might be helpful to try using another garbage collection algorithm.


    See the Adding/Modifying JVM Command Line Options section below.

    Adding and Modifying JVM Command Line Options

    Overview to change garbage collection algorithm in use:

    • Add or Modify JVM settings
    • Restart JasperReports Server
    • Watch memory usage
    Step Action
    1 Open /apache-tomcat/bin/setenv.bat
    2 Add the following JVM options to the JAVA_OPTS variable:
    • XX:+UseConcMarkSweepGC
    • XX:+CMSIncrementalMode
    • XX:+CMSIncrementalPacing
    • XX:CMSIncrementalDutyCycleMin=0 (5.0 JVM only)
    • XX:CMSIncrementalDutyCycle=10 (5.0 JVM only)
    3 Restart JasperReports Server
    4 Either have users use JasperReports Server or use a load testing tool (such as LoadRunner) to simulate peak load conditions.
    5 Watch the apache-tomcatwebappsjasperserver-proWEB-INFlogsgc.log and apache-tomcatwebappsjasperserver-proWEB-INFlogsjasperserver.log
    6 Watch for OutOfMemoryExceptions and PermGenSpace errors
    7 If either occurs, change the JVM heap space settings. See the Increase Heap Space And Perm Gen Space section below.

    Increase Heap Space And Perm Gen Space

    Step Action
    1 Open /apache-tomcat/bin/setenv.bat
    2

    If the error is an OutOfMemoryException, set the Xms and Xmx options to higher values in the JAVA_OPTS variable.


    For better performance, set the Xms and Xmx options to the same value.

    3

    If the error is a PermGenSpace error, set the XX:PermSize and XX:MaxPermSize options to higher values in the JAVA_OPTS variable.

    For better performance, set the XX:PermSize and XX:MaxPermSize options to the same value

    4 Restart JasperReports Server
    5 Either have users use the system or use a load testing tool (such as LoadRunner) to simulate peak load conditions.
    6 Watch the apache-tomcatwebappsjasperserver-proWEB-INFlogsgc.log and apache-tomcatwebappsjasperserver-proWEB-INFlogsjasperserver.log
    7 If the errors persist, repeat steps 2-6 until the errors disappear.
    8

    If the errors persist after reaching the maximum allowable heap sizes (usually around 1.3 gb), consider migrating to 64 bit hardware or use additional server hardware in a cluster with a load-balancing appliance.

    What's Next?

    For additional information, refer to the following:

    Written By

    This tutorial was written by Steve Park, Professional Services Consultant, June 2009.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...