tags:

views:

142

answers:

2

I realize that Java code will slow down when run in debugger.

Question is, will the code slow down simply by starting Java with these options:

Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n

??

Or does the slowdown only happen when you connect to the "debug port" and actually step through code using an IDE?

+3  A: 

No, simply enabling the debugging port will have no effect on runtime performance. At least I've never noticed any.

..

jarnbjo
that's not the question he is asking, he's talking about launching the JVM with debug options
Valentin Rocher
@Valentin - huh? What? Please explain why the command lines don't enable a debug port and hence answer the query.
Egwor
ok, seems like I had a sudden case of "shit in my eyes"...@jarnbjo : could you just make a void edit to your answer, so I can remove my downvote ?
Valentin Rocher
@Valentin No, you didn't, the initial answer was *"The presence of debugging information in the class files will only increase the class file size and has no impact on runtime performance. At least not with current VMs."*. This was not an answer to the question.
Pascal Thivent
I did in fact misread the question and was a little bit too quick to answer, but edited my answer when I realized my mistake. I'm not sure why the edit does not show though ...
jarnbjo
@jarnbjo, what does trigger the slow down?
Marcus
oh ok thanks @Pascal, thought I was hallucinating. Removed the downvote anyway.
Valentin Rocher
+1  A: 

First, to strictly answer your question - at least as stated in its title - -Xdebug only enables debugging support in the VM using JVMDI in JVMs prior to 5.0. So in itself, it doesn't do much. Moreover, JVMDI is deprecated since 5.0 in favor of JVMTI:

-Xdebug
Start with support for JVMDI enabled. JVMDI has been deprecated and is not used for debugging in J2SE 5.0, so this option isn't needed for debugging in J2SE 5.0.

So -Xdebug doesn't do anything anymore and the important part is:

-Xrunjdwp:<name1>[=<value1>],<name2>[=<value2>]...

or, starting with Java 5.0, the newer (that you should prefer as the JDWP agent in 5.0 uses the JVM TI interface to the VM rather than the older JVMDI interface):

--agentlib:jdwp=<name1>[=<value1>],<name2>[=<value2>]...

Now, to my knowledge, just loading the jwdp agent and/or configuring the JVM to listen for a socket connection on a given port don't have any noticeable performance impact. But connecting a debugger does.

Pascal Thivent