Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Java code slow down in debugger?

Tags:

Some CPU intensive routines get dramatically slower when run through a debugger. Why is this?

Currently I'm just using IntelliJ to step through code running in JBoss. When I start JBoss, I use these options:

set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=256m -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n %JAVA_OPTS% 

Is there a way to speed up the execution? Or to speed up certain method executions that I don't need to step through?


Update: Seems if I don't step over/into the CPU intensive routines (ie: Just run til a breakpoint set right after the routine), then the execution time is as if not in a debugger.

like image 610
Marcus Leon Avatar asked Feb 03 '10 21:02

Marcus Leon


People also ask

Does debug slow down?

Definitely debug logs slow downs the application performance.

Why does IntelliJ debugger take so long?

Remove breakpoints off your method and use them inside the method as that can cause your debug to take a very long time. Try running IntelliJ as admin. I had this issue at work where debugging was extremely slow and running as admin actually made it a lot faster.

How do I run a Java program in debug mode?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.


1 Answers

Some CPU intensive routines get dramatically slower when run through a debugger. Why is this?

Because the JITter won't optimize code as much (often, not at all) when debugging is enabled.

like image 105
Anon. Avatar answered Oct 01 '22 17:10

Anon.