I've got an Axis2 web service that just fell over on a client site it's throwing the following exception: java.lang.OutOfMemoryError: unable to create new native thread
I'm just pulling the logs off the site but in the interim I was wondering if anyone knew of any monitoring tools I could use to find a memory leak in a web application running in Tomcat.
Make a heap dump, and analyse it with Eclipse Memory Analyzer.
There are a few steps you can use to identify the memory leak.
Start with changing the start up parameters of the web service. Add the line
-XX:+HeapDumpOnOutOfMemoryError
which will capture a heap dump for you whenever the jvm encounters an OOM exception. You can use this information to get a good representation of what objects in memory were taking up all of the available memory. While waiting for the OOM to be replicated, you can look at a 2nd set of paramters to add to the start-up, the following logs the GC activity,-XX:+PrintGCDetails -verbose:gc -Xloggc:/log/path/gc.log
. With this data you can see if the OOM is occuring gradually or if it is happening quickly.Another path is to use a program like VisualVM, which can be used to profile the web service. This will attach to your running JVM (preferably on a development environment) and then attempt to stress test to find where the problem lies, Try JMeter to help with the stress Test. VisualVM is found in your JAVA_HOME/bin folder (v6 and above)
This could also be a case where it is not of a memory leak, but simply more load on the client side then expected. Look at tweaking the startup parameters to provide more memory (
-Xms
and-Xmx
)Unless your client can tell you the parameters which they passed before the problems occured, you will have to do a bit of investigation yourself until you find more information.
Daniel already covered jmap in his answer, so I wont go into that detail
Try VisualVM.