Why does the debugged program slow down so much when using method entry debugging?

点点圈 提交于 2019-11-27 08:13:42
Ichorus

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.

2 reasons:

  1. it has to add checks on every method entry (there is no option to tweak just some methods)
  2. method inlining becomes impossible (so small methods runs 10-100x times slower)

same goes to profilers and .net apps

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!