Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

debugging - Will Java app slow down by presence of -Xdebug or only when stepping through code?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...