Java: slow performance or hangups when starting debugger and stepping

Debugger performance can be affected by the following:

  • Method breakpoints will slow down debugger a lot because of the JVM design, they are expensive to evaluate. Remove method breakpoints and consider using the regular line breakpoints. To verify that you don't have any method breakpoints open .idea/workspace.xml file in the project root directory (or <project>.iws file if you are using the old project format) and look for any breakpoints inside the method_breakpoints node.
  • Show method return values option is enabled in the Debugger tool window. Try disabling this option to improve the performance.
  • Enable alternative views for Collections classes and Enable toString()’ object view options enabled in Settings (Preferences on macOS) | Build, Execution, Deployment | Debugger | Data Views. If toString() methods take a long time to complete, disable this option. Note that custom toString() methods can also change the semantics of the application when running under debugger in case the code inside these methods changes the state of your application.
  • Memory tab in the debugger toolwindow. It is updated on every debugger stop, try to minimize it to improve stepping performance.
  • Settings (Preferences on macOS) | Build, Execution, Deployment | Debugger | Data Views | Editor | Show values inline. Disable to improve performance.
  • Settings (Preferences on macOS) | Build, Execution, Deployment | Debugger | Data Views | Java | Predict condition values and exceptions based on data flow analysis. Disable to improve performance.
  • Enable Mute Renderers option in the Debug tool window Variables view context menu.

See also the following help sections:

41 comments
Comment actions Permalink

My debugger suddenly started to fail to start. I deleted all my breakpoints (~20) & that fixed it.

6
Comment actions Permalink

I'm experiencing the same problem running IntelliJ on my Mac.  Starting a java debugging session hangs IntelliJ 10+ seconds on every start.

4
Comment actions Permalink

"If toString() methods take a long time to complete, disable this option". After doing this I was able to step through the code without experiencing slowness.

3
Comment actions Permalink

My debugger has become very slow almost to the point of being unusable.  From the time I click the debug icon until it gets started can take unto 30 seconds.  Once is going its ok.  I have found a temporary solution by accident.  If I disconnect my wifi my debugger starts almost instantaneously!  Has anybody a better solution? 

1
Comment actions Permalink

Removing the method breakpoint made my debugging faster.. Before that is was none responsive.

1
Comment actions Permalink

Changing transport of debugger from socket to shared memory solved the issue for me

1
Comment actions Permalink

The same phenomenon also occurs in IntelliJ IDEA Ultimate 2018.2.4 and 2018.3 EAP + Payara 5.183.
It solved by eliminating all breakpoints.

1
Comment actions Permalink

Thanks, typo is fixed. I'm not sure I understand your first suggestion, please clarify.

1
Comment actions Permalink

 

Hello.

We have the same situation as Atjaden has.

Our application works in Run mode and hangs in Debug mode. Without break points. Idea 2017.3.2(Ultimate edition) under Linux.

Application is hanging on ( according to jstack):

"AWT-EventQueue-0" #25 prio=6 os_prio=0 tid=0x00007f1edcd26800 nid=0x7dc8 runnable [0x00007f1ea5c28000]

java.lang.Thread.State: RUNNABLE

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)

at java.lang.Class.getConstructor0(Class.java:3075)

at java.lang.Class.newInstance(Class.java:412)

at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.instanciate(OptimizedAccessorFactory.java:199)

at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:667)

at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:655)

at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:347)

at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:330)

at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:368)

at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:372)

at javax.xml.ws.Service.getPort(Service.java:188)

There is no one deadlock in this jtsack. It seems like it depends on count call of the method:

javax.xml.ws.Service#getPort(java.lang.Class<T>)

For example 10 times in works, but on 11 it hangs. And it has to be different classes.


I don't have permission to Atjaden's ticket. Have I to create new ticket?   


0
Comment actions Permalink

i forgot that in macbook pro you must add your hostname to the /etc/hosts. it solved the freezes.

0
Comment actions Permalink

trying to attach to a live chrome app fails too

0
Comment actions Permalink

I'm switching back to Eclipse. Even very simple statements cannot be executed line by line by pressing F8 because it takes 3 seconds even for simple assignments. I'm not going to renew my subscription

0
Comment actions Permalink

None of these worked for me and I did every single one of these plus, adjusted memory settings, adjusted emulator settings, I have read at minimum a dozen to two dozen articles surrounding this issue, and have followed every single recommendation here and elsewhere (e.g., stackoverflow).

I'm tired of workarounds. Workarounds are just that... workarounds are not solutions! I have also noticed that all workarounds for this issue eventually fail, like the disabling of the "toString()" in debug settings. It worked for a day then never worked again. Case and point, I performed every single one of the above suggestions and it seemed to work for about an hour of constant debugging and after that, failed on every instance of a Collection type.

In my case, every form of Collections (i.e., String[], int[][, List, ArrayList, HashMaps, etc.) are impacted. That tells me there is a resource management issue and could be memory, byte, buffering management or cleanup etc. Hanging issues, in my experience, always seem to fall around these types of resource management. As I mentioned, the one consistent observation in my case is that this falls very close to 100% failure on Collections objects. This does not occur on other objects or primitives.

0
Comment actions Permalink

Webstorm debugger on Chrome sometimes works slowly with 3-4 delay between actions when connected to localhost, connecting to 127.0.0.1 solves the problem.

This problem is intermittent, I still can't figure out under which conditions it would start but when it starts, it won't go away until you restart the workstation (Chrome or Webstorm restart doesn't work)

 

0
Comment actions Permalink

The bizarre but effective solution offered by jdavis413 sure helped me not totally wanna shift back to Eclipse, which breezes through during the SAME debugging. The response time has MAYBE improved 50% which might be psychological, as I do wanna stick to IJ, but nevertheless, still slower than E.

Why does Eclipse not react so weirdly to entries in the hosts ?? Why is IJ so peculiar about it ?

Update -I had to restart browser/server/vm for it to have any effect.

 Update - I had some version of IJ when I got my CentOS VM, then it updated and crazy things started to happen. I then just wiped it out and reinstalled and things are hunky-dory now. I am even starting to get along with the new Find window:)

Edited by rojajet
0
Comment actions Permalink

All of these settings are correct locally and I still get freezes from 5 to 10 seconds on every debug run.

I've allocated huge amounts of memory in both gradle, intellij natively, and also set my local host manually in /etc/hosts and still nothing.

0
Comment actions Permalink

Ticket created: https://youtrack.jetbrains.com/issue/IDEA-184594

It seems to happen with any project.

Unfortunately, I'm not able to test this issue on a newer version of IDEA due to security restrictions on my workstation. However, this problem was not happening at one time using this version of IDEA.

0
Comment actions Permalink

Got a couple of suggestions

  • why not refer to anyone using the actions command on the IDE and so this brings up all the breakpoints present in the application.
  • Also there's a type on this article - `verity` to be changed to `verify`.
0
Comment actions Permalink

May be related to problems resolving localhost name. Are you on Mac OSX? Make sure that you have

127.0.0.1       localhost 

in /etc/hosts and that it's the only localhost mapping there

0
Comment actions Permalink

Thank you Serge that fixed it for me.

TLDR:

git clone https://github.com/thoeni/inetTester

java -jar ./bin/inetTester.jar

Find the hostname that's output from the .jar

sudo nano /etc/hosts and add these two entries

127.0.0.1 <output-host-name>.local

::1 <output-host-name>.local


EDIT:

If you continue to have problems with a slowdown of intellij debugging even after applying the fix to /etc/hosts then run the inetTester again. My localhost name changed on me all of a sudden and the debugger started hanging predictably again.

Just run the inetTester again and add your new hostname to /etc/hosts with the 127.0.0.1 mapping and it should fix it again.

Edited by jdavis413
0
Comment actions Permalink

I had the same issue that drove me crazy. Finally fixed by changing the “project bytecode version” to 1.8 in Settings … Java compiler

0
Comment actions Permalink

very cool brother one

0
Comment actions Permalink

That sounds like a different problem than what I was having.  Mine hung only after stepping over a breakpoint.  It turned out to be a duplicate of https://youtrack.jetbrains.com/issue/IDEA-171027.  Perhaps restoring the debugger view will fix your issues as well, but if not, I would advise making a ticket so the JetBrains team can evaluate it more closely.

0
Comment actions Permalink
Edited by Egor Ushakov
0
Comment actions Permalink

My debugger seemed to start hanging randomly after working well for almost a year. I'm on a Windows 7 machine with IDEA 2017.1.4.

I do not have any method breakpoints (I've removed ALL breakpoints except one to test with, which is not a method breakpoint), and I disabled the toString option mentioned above, yet the problem persists.  I've tried switching to Shared Memory instead of a socket, and that didn't help either.  Any other suggestions?

Edited by Atjaden
0
Comment actions Permalink

I made some research regarding Method Breakpoint slowness (http://www.smartik.net/2017/11/method-breakpoints-are-evil.html ).
To make the long story short, it seems that the root issue is that Method Breakpoints are implemented by using JDPA's Method Entry & Method Exit feature. This implementation requires the JVM to fire an event each time any thread enters any method and when any thread exits any method.

If this is the case, I would like to propose an improvement. When a user tries to set a breakpoint on a method's signature, the debugger can try to find the method and (behind the scenes) set a breakpoint at its first instruction. In practice, this means you can handle method breakpoints exactly like regular breakpoints.

Only breakpoints for method exit would require using the expensive Method Exit feature. 

From my understanding eclipse's developers improved Method Breakpoint implementation as described.

I would like to know how Method Breakpoints are implemented by intellij.

Edited by Gabi Beyo
0
Comment actions Permalink

my debugger keeps holding onto old compiled typescript sources in my angular app and loading them into the IDE automatically ontop of the ones in my project breakpoints and all.

refuses to relent

cannot debug

refuses to hit breakpoints either

lost my last contract from this kind of stuff trying to deliver

have to rebuild, redeploy, restart all over again

???

Edited by Meanstack
0
Comment actions Permalink

Oh, I meant bringing up the actions tab for everything that you can do on `IntelliJ`. To get breakpoints, builds, settings, preferences,...

0

Please sign in to leave a comment.

Have more questions?

Submit a request