jLuger.de - Finding infite loops in Java

In Fixing memory leaks in Java I've introduced tools to find memory leaks. Recently I had the problem that some conditions caused a infinite loop in a Java program when I couldn't connect the debugger to it. So I've searched for a way to get some inside on what is happening and found jstack.

jstack is part of the JDK and expects the pid (process id) of the Java program as an argument. It will then print the complete stack trace of the program onto standard output. With the help of jps (see Fixing memory leaks in Java for more information about it) I've got the pid. Now its easy to get a stack trace. One stack trace is nice but to get to know what is going on you need several taken at different times. I've used a simple command script to them:

for /L %i in(1,1,1000) do jstack 3824 > stack%i.txt

This will create thousand files with stack traces of the program with the pid 3824. Of course I didn't go through one thousand files. Instead I've skipped creation when I thought I had enough samples but this point was time based and so I've just entered a large number to get sure that I've got enough time.

To get the differences between the samples I've viewed two files that where created consecutively. The interesting part are the methods below the changes. One of them has a problem to return and thus is repeatedly calling the others.