Archive for December, 2010

Using strace to attach to a multi-threaded process (like a JVM/Java)…

Friday, December 10th, 2010

When using strace to attach to a process that is running many threads, use the following format:

strace -f -c -p PID  -o /tmp/outfile.strace

This will capture system calls from all threads within the process.

Tomcat troubleshooting – Thread Stack Trace

Thursday, December 2nd, 2010

One of the best troubleshooting tools when using tomcat is to cause the JVM to print a thread stack trace for each current thread. This will provide insight into what all threads are currently doing.

Note that if you wait until there is a problem to take the first stack trace, it will be very difficult to solve any problems. Take a look now and see what the current behavior is so that it will be easier to troubleshoot later.

To get a thread stack trace, use the following command:

sudo -u tomcat jstack PID > /tmp/$(date +%Y%m%d)-jvm-thread-stack.txt