Why does the debugged program slow down so much when using method entry debugging?
Solution 1:
The short answer is that execution runs through the interpreter when method entries are set. I don't think there is anyway around this...
This used to be the case for all code running in debug mode but it was enhanced in 1.4... now HotSpot works for 'full-speed' debugging except in the case of method entries and exits, watchpoints and when single stepping or in methods that contain breakpoints.
Solution 2:
2 reasons:
- it has to add checks on every method entry (there is no option to tweak just some methods)
- method inlining becomes impossible (so small methods runs 10-100x times slower)
same goes to profilers and .net apps
Solution 3:
I would assume that the debugger needs to wake up for every method call to see if it matches the one(s) that were selected to break. Because it has to check every method call for a potential match before it can execute it is considerably slower than if it does not have to do all these checks.