The World's Most Widely Used Business Intelligence Software
0

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:

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:

  • Dcom.sun.management.jmxremote  \
  • Dcom.sun.management.jmxremote.port=9004 \
  • Dcom.sun.management.jmxremote.authenticate=false \
  • Dcom.sun.management.jmxremote.ssl=false 
3 Restart JasperServer 
4 Launch the <java-home>/bin/JConsole.exe application 
5

Click the Remote tab and enter the following values:

  • Host or ip: <servername> (localhost if running locally)
  • Port: 9004
  • Username and Password: <leave blank> 
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. 

Return to top

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:

  • Xgcpolicy:optavgpause \
  • Xgcthreads(n) 
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. 

Return to top

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. 

Return to top

 

What's Next?

For additional information, refer to the following:

Written by

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