title: How to help java tomcat processes to regain used memory?
body: <p>We are running an web application that is using Java 64bit 5 gigs of -Xmx of maximum heap size.  We have no control over the java code.  We can only tweak configuration parameters.  The situation that we are facing is that the java processes after it takes the full heap allocated at start up, it starts acting very responding very slow to web site requests.  My guess is that is waiting for the GC to collect unused memory objects.</p>
  
  <p>The image below will show you a image of top in linux that shows the critical situation of the processes.</p>
  
  <p><a href="http://cp.images.s3.amazonaws.com/ForumImages/java-gc-issue.jpg" rel="nofollow noreferrer">top image of java process http://cp.images.s3.amazonaws.com/ForumImages/java-gc-issue.jpg</a></p>
  
  <p>Is there any way, we can help java regain the used memory inside the allocated space.  </p>
  
  <p>EDIT 1:
  I used some of the answers below to be able to get to the answer of my question. Since my question was too difficult to answer, and it turned out to be a discussion.  I will post how I was able to monitor the GC cycles and I will pick the answer with more votes.  I used jconsole through real vnc viewer to be able to hook from my windows machine to my linux machine running tomcat.  </p>
  
  <p>I used this parameters to start the java processes:</p>
  
  <pre><code>-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
  </code></pre>
  
  <p>This is the type of output I got, from jconsole through vnc viewer.
  <a href="http://cp.images.s3.amazonaws.com/ForumImages/Sample_GC_Image.jpg" rel="nofollow noreferrer" title="Sample GC Image">GC Sample Image http://cp.images.s3.amazonaws.com/ForumImages/Sample_GC_Image.jpg</a></p>