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?
Method breakpoints: suspend the program upon entering or exiting the specified method or one of its implementations, allowing you to check the method's entry/exit conditions. Field watchpoints: suspend the program when the specified field is read or written to.
A breakpoint is a signal that tells the debugger to temporarily suspend execution of your program at a certain point in the code. To define a breakpoint in your source code, right-click in the left margin in the Java editor and select Toggle Breakpoint.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With