This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 201387

Summary: Java Debugger Conditional Breakpoint Performance
Product: debugger Reporter: rhollencamp
Component: JavaAssignee: Martin Entlicher <mentlicher>
Status: NEW ---    
Severity: normal Keywords: PERFORMANCE
Priority: P3    
Version: 7.0.1   
Hardware: PC   
OS: Windows 7 x64   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Overview of memory utilization during debugging

Description rhollencamp 2011-08-28 15:15:52 UTC
Created attachment 110260 [details]
Overview of memory utilization during debugging

Conditional breakpoint performance when debugging a Java app is terrible. Test case:


	public static void main(String[] args) {
		for (int i = 0; i < 50000; i++) {
			doWork(i);
		}
	}

	private static void doWork(int i) {
		return;
	}



Place a breakpoint on the call to doWork, and set a condition on the breakpoint: i == 49000. Start debugging. On my machine it takes over two minutes to hit the breakpoint. Looking at the memory utilization using VisualVM, Netbeans is thrashing pretty hard, creating all kinds of objects that are then garbage collected.

Workaround that I use is to put a block of code before the call to doWork:
if (i == 49000) {
        System.out.println("foo");
}

I then place a breakpoint on the println; the breakpoint is reached almost instantly.
Comment 1 Martin Entlicher 2011-09-05 16:03:05 UTC
The problem is that the breakpoint condition is evaluated on the client side. The breakpoint breaks execution every time, the condition is evaluated and when it's false, the execution is resumed again. This makes the conditional breakpoints very slow.

I do not think that there is a way how to reliably execute conditions from the breakpoint location on the server side.

We can try to evaluate possible approaches for the next release.
Comment 2 peathal 2013-02-24 16:33:01 UTC
Same problem here for NetBeans 7.3.

A simple workaround is to put the if statement directly in the code and an unconditional breakpoint inside the if. Couldn't one do similar for the implementation? Why is the debugging 'server' limited in this way and the debugging client not?