I would like to take a heap dump and a thread dump of my Java app. Now I know how to do this if I run the Java app from a command line using java.exe. But my app is started as a Windows service using Apache's Proc Run. Thus, in one example, I have tomcat.exe running. I tried running VisualVM but it doesn't see tomcat.exe. I guess I have been so used to running things from the command line that I haven't looked into getting thread dumps or heap dumps in other environments. Anyone know what the best way to get such dumps would be?
I'm not sure it will work in your case, but I was able to do this for WebStart application which also doesn't display the text mode console: go to Java Control Panel and on the Advanced tab activate Java console/Show console. When the application starts, it should display a regular window (ie. not the text mode console) which will contain the JVM console output. There are several keys listed in the output when the console appears; pressing these keys initiates some actions, including Thread Dump. Not sure about Heap Dump, though.
This might not work if it really runs as a Windows service, with disabled desktop interaction.
On the other hand, I'd expect that tomcat will start the applications in separate processes, using java.exe (at least OAS does it this way). Don't you see any java.exe in VisualVM?
No, there is no java.exe in Task Manager. I have one process named tomcat6.exe*32, and another named container.exe*32 (yes, we are running 32-bit JVMs on a 64-bit system). I'll experiment with the Java Control Panel suggestion and see if that works (I can always enable desktop interaction on the service).
I tried the Java Control Panel settings. Interestingly enough, I get a console for tomcat6.exe, but not for container.exe. Looking at Process Explorer, tomcat6.exe is using the JRE JVM, while container.exe is using the JDK JVM, that could explain the difference (they are both the same Java version). But I noticed two other processes with the JRE loaded, but no console showed up for them.
I tried using jmap to get a thread dump but Windows displays the message "Not enough storage is available to process this command." and none of the workarounds for this error that I found while googling have yielded any results (apparently there are multiple "storage" areas and I haven't found a web page that tells me how to increase the one I need).