title: Can I get Tomcat running as a service to dump heap?
body: <p>I am attempting to have Tomcat, which is currently running as a service on a Windows 2003 box, dump heap on an <code>OutOfMemoryError</code>.</p>
  
  <p>(Tomcat is running Hudson, which is reporting a heap space problem at the tail end of my build.  Running the build manually produces no such error.  The Hudson guys need a heap dump to get started.)</p>
  
  <p>As instructed elsewhere, I've told the Apache Service Monitor to configure the JVM it uses to run Tomcat to dump heap when an <code>OutOfMemoryError</code> is encountered by adding the following to the JVM options:
  -XX:+HeapDumpOnOutOfMemoryError
  Then I run the build again.  Sure enough, it reports there was a heap error.  I scan the entire disk looking for the default <code>java_pid123.hprof</code> file (where obviously <code>123</code> is replaced by the PID of the JVM).  No <code>.hprof</code> files exist anywhere.</p>
  
  <p>I am caught in a catch 22: I need the heap dump for the Hudson guys to fix their memory leak, but I can't get the heap dump if I run Hudson under Tomcat.</p>
  
  <p>Is there some special way, when Tomcat is running as a Windows service, to get a heap dump from it on an OutOfMemoryError?</p>
  
  <p>The other thing I've tried is to tell it, on the Startup and Shutdown tabs, to use the "Java" option instead of the "jvm" option.  I believe this should tell the Service Manager to attempt to start Tomcat with a Java executable command instead of launching the <code>jvm.dll</code> directly.  When I do this, the service won't start.</p>
  
  <p>Surely someone else has had a similar problem?</p>