How can I help the Java Tomcat process regain used memory?
We are running a web application using java 64bit 5 gigs - Xmx maximum heap size We have no control over java code We can only adjust the configuration parameters The situation we face is that after the java process allocates the full heap after startup, it starts to respond very slowly to website requests My guess is to wait for GC to collect unused memory objects
The following figure shows the top image in Linux, showing the severity of the process
top image of java process http://cp.images.s3.amazonaws.com/ForumImages/java-gc-issue.jpg
What can we do to help Java regain the used memory in the allocated space
Editor 1: I use the following answers to get the answers to my questions As my question was too difficult to answer, it turned out to be a discussion I will post how I can monitor GC cycles and I will choose more voting answers I can hook from my windows machine to a Linux machine running Tomcat using jconsole through a real VNC viewer
I use these parameters to start the java process:
-Djava.awt.headless=true -server -Xms512m -Xmx5120m -Dbuild.compiler.emacs=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
This is the output type I got from jconsole to VNC viewer GC Sample Image http://cp.images.s3.amazonaws.com/ForumImages/Sample_GC_Image.jpg
Solution
I advise you not to guess Get some data to know exactly what happened You can use visual GC to see what is happening
If you are filling the perm space, you can't do much
Which JVM? If it is 5 or higher, there are other parameters that can be adjusted in addition to the maximum heap size see http://blog.springsource.com/2008/10/14/optimising-and-tuning-apache-tomcat-part-2/