Java profiling with HAT

I’m doing some Java profiling of a Tomcat 5.5 webapp with HAT, The Java Heap Analysis Tool. Here’s some steps to make it work:

  • Download HAT from http://hat.dev.java.net/.
  • Open the Tomcat Monitor app, click configure, Java tab, and add the following line to Java Options: -Xrunhprof:file=dump.hprof,format=b,heap=all
  • You may need to add more memory to Tomcat as well (Maximum memory pool).
  • To launch it on the command-line:
    java -jar hat.jar -port 7002 “C:\Program Files\Apache Software Foundation\Tomcat 5.5\dump.hprof”
  • If you run into memory problems w/ hat, give it more:
    java -XX:PermSize=128m -XX:MaxPermSize=128M -Xms700M -Xmx700M -jar hat.jar -port 7002 “C:\Program Files\Apache Software Foundation\Tomcat 5.5\dump.hprof”
  • View the Hat webapp at http://localhost:7002/
  • The docs included w/ the HAT download outline the capabilities of the HAT app pretty well.

2 Responses to “Java profiling with HAT”

  1. Eric Says:

    Hi:

    I am trying to get a heap dump from a remote server. The documentation at the website is a little confusing. Do I run -Xrunhprof on the server or on the client? How do I generate a dump on my local machine?

    Thanks.

  2. roger rubygems Says:

    Yes but how do you give more memory to jhat, which has no jar? :)
    -r

Leave a Reply