Tomcat version: 7.0.40
Redhat: 2.6
gcviewer: 1.35
[TOMCAT_HOME]: Tomcat home directory
[SERVICE_NAME]: Tomcat service name
Configuration (Linux)
The garbage collection in Tomcat can be enabled through the steps as listed below:
1. Look for "setenv.sh" file at "[TOMCAT_HOME]\bin" directory.
2. Add in the entries below to "setenv.sh".
CATALINA_OPTS="-XX:+PrintGCDetails -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:[TOMCAT_HOME]/logs/gc.log"
3. Restart the Tomcat instance, check the [TOMCAT_HOME]/logs directory, gc.log file is generated.
Open and observe the garbage collection log
1. Browse to "http://sourceforge.net/projects/gcviewer/files/" to download gcviewer.
2. Open the garbage collection log file. You will be able to analyze garbage collection log and the memory usage by Tomcat.
Configuration (Window)
Assume the Tomcat service has been configured, you can run the command below in [TOMCAT_HOME]\bin to install service name
service install [SERVICE_NAME]
1. Double click "tomcat7w.exe" located at [TOMCAT_HOME]\bin directory, the screen as shown below will be displayed. Select "Java" tab.
2. Append the text below to "Java Options" textbox
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintHeapAtGC
-Xloggc:[TOMCAT_HOME]\logs\gc.log
3. The log file will be generated at [TOMCAT_HOME]\logs folder
4. Open log file with gcviewer, the memory usage will be displayed as shown in the screen below
No comments:
Post a Comment