4

Ok, so I've got a genetic algorithm running in netbeans, and its been running for like 5 hours and seems to have entered an infinite loop. Is there any way that I can attach a debugger to it? or at least get some clue as to where it is in the code? I'd rather not sit around for another 5 hours while I wait for it to happen again.

wfbarksdale
  • 7,498
  • 15
  • 65
  • 88
  • 1
    there's no need for code here, he's simply asking if he can attach a debugger at runtime. upvoted the question. – user237419 Apr 22 '11 at 07:43

1 Answers1

10

A simple way to get some basic information from your running program is to run jstack on it, it will print stack traces of all threads in your code. Do that several times and you should have a good idea what is wrong.

Use jps to find out the id of your JVM like and then use jstack with that ID:

$ jps
10664 Jps
7141 org.eclipse.equinox.launcher_1.2.0.v20110124-0830.jar
$ jstack 7141

VisualVM provides similar information, if you prefer a GUI application.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • ill give it a shot, gotta go figure out what jstack is though :) – wfbarksdale Apr 22 '11 at 07:37
  • 1
    VisualVM (part of the JDK) is also able to produce a stacktrace –  Apr 22 '11 at 07:38
  • Yes, it's probably easier. I'm just used to having to do that with servers that are behind restrictive firewalls and low-bandwidth connections. In those cases `jstack` is much easier to handle ;-) – Joachim Sauer Apr 22 '11 at 07:57