Search code examples
javatomcatmemoryheap-memorytomcat6

How do get heap dump and thread dump for Tomcat in Mac


I am trying to analyize the memory usage for a application that is being deployed in Tomcat.

I need to get the heap dump and thread dump while the application is running in tomcat.

Can anybody let me know how to get those dumps in mac from terminal for Tomcat.

I tried getting tomcat PID using "ps ux | grep apache" and then did "kill -3 PID", but nothing happens...


Solution

  • it depends on the JVM you use to run your Tomcat. I strongly recommend to run all applications and servers using the JDK (in case of HotSpot, which you likely use). Then you should have multiple utilities at hand:

    • jps - for finding your pid
    • jstack - for getting thread dump
    • jmap - for getting the heap dump.

    or you use jvisualvm which bundles all the tools into a nice ui. Last, but not least, it is possible that you have gotten the wrong PID :-)