IBM JVM Garbage Collection Tuning Tutorial
Introduction
This tutorial covers basic performance diagnostic and tuning techniques for IBM JVM garbage collection. The tutorial focuses on basic memory problems and present command line settings that act as a starting point for improving garbage collection performance when running JasperServer.
Product Version
The tutorial works with any version that works with Java 5.0 or later.
User
Administrator
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
Assumption: Use of bundled Tomcat included with JasperServer. Adapt as needed for other application servers and platforms.
Diagnosing Memory Problems
Overview of diagnosing memory problems:
- Launch JConsole
- Have users use JasperServer or simulate load with QA tool
- Watch memory usage
| Step | Action |
| 1 | Edit <js-install>/apache-tomcat/bin/setenv.bat
|
| 2 |
Add the following JVM options to the JAVA_OPTS variable:
|
| 3 | Restart JasperServer |
| 4 | Launch the <java-home>/bin/JConsole.exe application |
| 5 |
Click the Remote tab and enter the following values:
|
| 6 | Click the Memory tab |
| 7 | Either have users use JasperServer 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, this is an indication of either a memory leak or garbage collection problem. See the Adding/Modifying JVM Command Line Options section below.
|
Adding/Modifying JVM Command Line Options
Change garbage collection algorithm in use:
- Add/Modify JVM settings
- Restart JasperServer
- Watch memory usage
| Step | Action |
| 1 | Edit <js-install>/apache-tomcat/bin/setenv.bat |
| 2 |
Add the following JVM options to the JAVA_OPTS variable, where (n) is between 1 and the number of processors on the server:
|
| 3 | Restart JasperServer |
| 4 | Either have users use JasperServer or use a load testing tool (such as LoadRunner) to simulate peak load conditions |
| 5 | Watch the <js-install>\apache-tomcat\webapps\jasperserver-pro\WEB-INF\logs\jasperserver.log |
| 6 | Watch for OutOfMemoryExceptions |
| 7 | If an error occurs change the JVM heap space setting. See Increasing Heap Space and Perm Gen Space section below. |
Increasing Heap Space and Perm Gen Space
Change JVM Heap and Perm Gen Settings:
- Add/Modify JVM settings
- Restart JasperServer
- Watch memory usage
| Step | Action |
| 1 | Edit <js-install>/apache-tomcat/bin/setenv.bat |
| 2 |
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 | Restart JasperServer |
| 4 | Either have users use the system or use a load testing tool (such as LoadRunner) to simulate peak load conditions |
| 5 | Watch the <js-install>\apache-tomcat\webapps\jasperserver-pro\WEB-INF\logs\jasperserver.log |
| 6 | If the errors persist, repeat steps 2-5 until the errors disappear |
| 7 | 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:
- JasperServer Ultimate Guide
- JasperServer Pro Admin Guide, located in the <jasperserver-install>\docs folder.
- Mash That Trash - Incremental Compaction in the IBM JDK Garbage Collector
- Using JConsole
Written by
This tutorial was written by Steve Park, Professional Services Consultant, June 2009
Language

