Java 使用 Eclipse IDE 在调试模式下加速 Tomcat
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1369487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Speeding up Tomcat in debug mode with Eclipse IDE
提问by andersonbd1
Running Tomcat through eclipse works fine in non-debug mode, but not in debug mode. When I try to start the Tomcat server in debug mode, the console output looks fine for a while, but then starts slowing down and eventually just stops, pegging the cpu at 100%. I don't think it's relevant, but just in case - here's the console output right about when it starts slowing down and eventually stopping (by stopping I mean no more console output, but still 100% cpu).
通过 Eclipse 运行 Tomcat 在非调试模式下可以正常工作,但在调试模式下则不行。当我尝试以调试模式启动 Tomcat 服务器时,控制台输出在一段时间内看起来不错,但随后开始变慢并最终停止,将 cpu 固定在 100%。我认为这无关紧要,但以防万一 - 这是控制台输出,关于它何时开始变慢并最终停止(停止我的意思是没有更多的控制台输出,但仍然是 100% cpu)。
2009-09-02 14:35:30,859 INFO NONE org.springframework.context.weaving.DefaultContextLoadTimeWeaver:72 - Found Spring's JVM agent for instrumentation
2009-09-02 14:35:49,562 INFO NONE org.springframework.beans.factory.support.DefaultListableBeanFactory:414 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ed889d: defining beans [...
2009-09-02 14:37:31,031 INFO NONE org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean:221 - Building JPA container EntityManagerFactory for persistence unit ...
I tried everything I could think of to fix it:
我尝试了所有我能想到的方法来修复它:
- cleanesd tomcat working directory
- restarted eclipse
- restarted Windows
- refreshed/cleaned all projects
- cleanesd tomcat 工作目录
- 重新启动日食
- 重新启动的 Windows
- 刷新/清理所有项目
I first had this problem last week using eclipse ganymede. I had been running fine in debug-mode for several months prior to this issue. I didn't make any significant changes to our project that would cause this. Eventually, I upgraded to eclipse galileo which solved my problem. Now 2 days later, I'm having the same problem in galileo. Like I said it works fine in non-debug mode. Any help is much appreciated.
上周我第一次遇到这个问题,使用 eclipse ganymede。在出现此问题之前几个月,我一直在调试模式下运行良好。我没有对我们的项目进行任何会导致这种情况的重大更改。最终,我升级到 eclipse galileo 解决了我的问题。现在 2 天后,我在伽利略中遇到了同样的问题。就像我说的,它在非调试模式下工作正常。任何帮助深表感谢。
I should add that other things work in debug mode - for instance junit tests, so it is something specific to tomcat.
我应该补充一点,其他东西在调试模式下工作 - 例如 junit 测试,所以它是特定于 tomcat 的东西。
采纳答案by andersonbd1
I've gotten through the issue! Once I figured it out, I remember that this has happened before. I cleared all my breakpoints and it works fine. I have no idea why that would cause the outcome that is does, but it works.
我已经解决了这个问题!一旦我想通了,我就记得以前也发生过这种情况。我清除了所有断点,它工作正常。我不知道为什么这会导致结果,但它有效。
回答by Chris Goddard
I just ran into this problem myself, and this solution helped me out. However - I only had 1 breakpoint, rather than the 20+ of other posters. My one breakpoint, however, was a method breakpoint and not a line breakpoint - I wonder if the multitude of method calls at tomcat startup combined with the method breakpoint could be causing this problem... I just tried a small experiment:
我自己刚刚遇到了这个问题,这个解决方案帮助了我。但是 - 我只有 1 个断点,而不是 20 多个其他海报。然而,我的一个断点是一个方法断点而不是一个行断点 - 我想知道在 tomcat 启动时的大量方法调用与方法断点相结合是否会导致这个问题......我只是尝试了一个小实验:
- Setting a line breakpoint and starting debug mode - 5 second startup (normal)
- Setting a method breakpoint and starting debug mode - ..... not willing to wait (> 90 seconds).
- 设置行断点并启动调试模式 - 5 秒启动(正常)
- 设置方法断点并启动调试模式 - ..... 不愿意等待(> 90 秒)。
I'm guessing this is the problem.
我猜这就是问题所在。
回答by Jamal
Change default logging level from:
从以下位置更改默认日志记录级别:
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
To :
到 :
<root>
<level value="OFF" />
<appender-ref ref="ConsoleAppender" />
</root>
回答by vsc
I had this same problem in Galileo. Fast run but crawling debug. Thanks to the posts above, I cleared all the breakpoints and restarted Tomcat. That magically fixed the problem. fyi - I had 2 method breakpoints and other line breakpoints earlier. I did the tests to confirm the above theory about method breakpoints slowing down. Here's what I found. Looks like it's not the method breakpoint which is the problem, the problem was the method breakpoint which was still showing up in the breakpoints list in debug view, but was not existing in the code. I mean I changed the parameters of that method but the old breakpoint with older parameters was still existing in the breakpoint list. That was the culprit, when I removed that, the other method breakpoints did not slow down the server. So looks like eclipse was trying to search for something non-existing which seems to have slowed it down. Hope this helps.
我在伽利略中遇到了同样的问题。快速运行但爬行调试。感谢上面的帖子,我清除了所有断点并重新启动了Tomcat。这神奇地解决了这个问题。仅供参考 - 我之前有 2 个方法断点和其他行断点。我做了测试以确认上述关于方法断点变慢的理论。这是我发现的。看起来问题不是方法断点,问题是方法断点仍然出现在调试视图的断点列表中,但不存在于代码中。我的意思是我更改了该方法的参数,但带有旧参数的旧断点仍然存在于断点列表中。那是罪魁祸首,当我删除它时,其他方法断点并没有减慢服务器的速度。所以看起来 eclipse 试图寻找一些不存在的东西,这似乎减慢了它的速度。希望这可以帮助。
回答by Rohitdev
I too stumbled upon this issue.
我也偶然发现了这个问题。
I closed all the irrelevant projects. Cleared out my breakpoints. Increased STS VM memory. Follow this blog: http://searchforsolutions.wordpress.com/2011/12/01/eclipse-jvm-settings-for-optimized-performance/Disabled the JBoss tool validators and all other validators.
我关闭了所有不相关的项目。清除了我的断点。增加了 STS VM 内存。请关注此博客:http: //searchforsolutions.wordpress.com/2011/12/01/eclipse-jvm-settings-for-optimized-performance/禁用 JBoss 工具验证器和所有其他验证器。
Now STS works like a charm!
现在 STS 就像一个魅力!