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:
- Diagnose memory problems
- Add/Modify JVM command line options to improve garbage collection performance
- Increase heap space and perm gen space as needed
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:
|
3 | Restart JasperReports Server |
4 | Launch the /bin/JConsole.exe application |
5 | Click the Remote tab and enter the following values:
|
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: Whereas a situation where garbage collection is inadequate or nonexistent will look like this: 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.
|
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:
|
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.
|
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:
- JasperReports Server Ultimate Guide
- JasperReports Server Professional Administrator Guide, located in the docs folder
- Tuning Garbage Collection with the Java 5.0 Virtual Machine
Written By
This tutorial was written by Steve Park, Professional Services Consultant, June 2009.
Recommended Comments
There are no comments to display.