现象
Method Breakpoints may dramatically slow down debugging
debug模式启动:
● 启动过程非常慢,console与运行日志处于卡顿状态
● 调试的时候运行非常慢,console与运行日志处于卡顿状态
定位
From the JetBrains Team: “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 make the long story short, it seems that the root issue is that Method Breakpoints are implemented by using JPDA’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.
来自 JetBrains 团队:“由于 JVM 设计,方法断点会大大降低调试器的速度,评估它们的成本很高。删除方法断点并考虑使用常规行断点。
具体可参考官方文章说明:
https://intellij-support.jetbrains.com/hc/en-us/articles/206544799-Java-slow-performance-or-hangups-when-starting-debugger-and-stepping
结论:
就是你打的断点太多,调试成本太高,所以造成卡顿
解决
关掉项目不必要的breakpoint, 建议每次搬完砖后清除历史的breakpoint,如果需要记录也可以用BookMark进行标记记录。