Kill -3 to Get Java Thread Dump

Generating Thread Dump on Sun JDK with Timestamp


You can use VisualVM utility provided in JDK 6.0. You can connect to your Java5 application using visualvm and can get/compare thread dump, memory dump etc.

Thread dump in a separate file with tomcat?

Thread-dump is always written to stdout and Tomcat redirects stdout to catalina.out by default. You can change where it redirects the stdout to but you can't separate thread-dump from other things written to stdout.

Sounds like you have other debug information written to catalina.out. Maybe you can get around this issue by writing all your debug messages to your own log so catalina.out is reserved for thread-dump and a few other things.

See my answer to this question on how to create your own log files,

How to configure logs/catalina.out of tomcat 6 for per-app. (Configure web-app specific log file for sys.out, sys.err)

Thread Dump during Full GC

You can't obtain any detailed information during a GC. You can now obtain the size of the various heaps via jstat but if your full GC is a stop-the-world- collection it means that everything else has stopped.

Additionally if you could obtain this information, it is unlikely to be what you need to know, it is just one random sample so unless there is only one place which is triggering a gc e.g. a call to System.gc(), or only one place allocating, it won't be so useful.

If you want to know where System.gc() is being triggered you can use instrumentation (or a modified System class) to do a stack trace where it is explicitly called. I have done this before and found it was the DGC. https://plumbr.eu/blog/garbage-collection/rmi-enforcing-full-gc-to-run-hourly

If you want to know where the highest allocation rate is, I suggest using a memory profiler. That is what the tools is for. It can show you stack traces of where the most/largest objects are being created.

Java thread dump: `WAITING (on object monitor)` line not followed by `waiting on 0x1234` line

It seems that I saw a problem where there is actually no problem.



Related Topics



Leave a reply



Submit