简体   繁体   English

Java进程cpu使用率增加

[英]Java process cpu usage increases

I have a multi-player java game server. 我有一个多人Java游戏服务器。 Everything was working stable since my last additions to the code. 自从我上次添加代码以来,一切工作都保持稳定。 What can be the cause of unusual cpu usage spikes? 是什么原因导致异常的CPU使用率飙升? After starting the server, it's around 10-20%. 启动服务器后,大约占10%到20%。 After some time, like 1-2 hours, cpu jumps to 107% and 207% and so on. 一段时间后,例如1-2小时,CPU会分别跳到107%和207%,依此类推。 After 10 hours, it will probably be 1109%. 10小时后,可能为1109%。 I am using netty, c3p0. 我正在使用netty,c3p0。 Running this on a powerful dedicated ubuntu machine. 在功能强大的专用ubuntu机器上运行它。

Thanks in advance. 提前致谢。

Read this: http://m.javaworld.com/community/node/8036 阅读此: http : //m.javaworld.com/community/node/8036

Probably you have some form of memory leak. 可能您有某种形式的内存泄漏。

It's hard to answer without details, but a good start is to use tools to diagnostic the program behavior. 没有细节很难回答,但是一个好的开始是使用工具来诊断程序行为。

Using JVisualVM (bundled with the JDK) can help you find if CPU is used by your program or garbage collector. 使用JVisualVM(与JDK捆绑在一起)可以帮助您查找程序或垃圾回收器是否使用了CPU。

A memory leak can lead the garbage collector to run excessively. 内存泄漏可能导致垃圾收集器过度运行。

After analyzing whole code, I found an infinite loop which could happen in some cases. 在分析了整个代码之后,我发现了在某些情况下可能发生的无限循环。 JVisualVM helped me find this bug. JVisualVM帮助我找到了这个错误。

Thanks for the help. 谢谢您的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM