tweak tomcat (jvm) to troubleshooting

Before making any changes ask yourself why.To validate your thoughts use jconsole/visualvm


For setting up jmx (jconsole) add this to you startup and restart your app. 
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090  
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false



Issue : The app stops responding for a while.
In my case it was the garbage collection.
turn on garbage collection detail logging for the application.
ADD : set JAVA_OPTS=-XX:+PrintGCDetails -XX:-HeapDumpOnOutOfMemoryError -verbose:gc  to the startup options/catalina.sh


To measure the performance of garbage collection we simply enable garbage collection logging.
This is done by adding the following JVM options to the CATALINA_OPTS variable in the bin/setenv.sh|bat file for your Tomcat instance.

-Xloggc:$CATALINA_HOME/logs/gc.log or Xloggc:%CATALINA_HOME%/logs/gc.log
-XX:+PrintHeapAtGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps or -XX:+PrintGCDateStamps
-XX:-HeapDumpOnOutOfMemoryError


Error : Java.lang.OutOfMemoryError: PermGen space
Increase permanent generation memory allocation.
ADD : set JAVA_OPTS=-Xms128m -Xmx192m -XX:MaxPermSize=256m 


Thread Pooling 
Thread pooling is not enabled by default. Enable it with this command-line setting:
 -Dsun.rmi.transport.tcp.connectionPool=true
With the connectionPool enabled, threads are created only if there is no thread in the pool that can be reused.  In the current implementation of the connection Pool, the RMI connectionHandler threads are added to a pool and are never removed.  Enabling thread pooling is not recommended for applications that have only limited RMI usage.Such applications have to live with these threads during the RMI off-peak times as well.Applications that are mostly RMI intensive can benefit by enabling
the thread pooling because the connection handlers will be reused, avoiding the additional memory usage when creating these threads for every RMI call.