Threads are always increasing

空扰寡人 提交于 2021-01-26 21:47:07

问题


I've just installed SmartFoxServer.

Thread count in thread pool at Dashboard are constantly increasing after restarting Sfs, and never decrease again until next restart. If I increase thread pool limit, thread count increase up to that limit.

Any extension or services are not running yet, and thread count increases up to 1232 in 10 minutes. So this doesn't seem like a memory leak, because no extension code is involved, just plain SmartFox.

I've tried version 2.9, but results didn't change.

What may cause Sfs threads to that kind of behavior without even running an extension?


回答1:


You have memory leaks.

» Memory leaks

In Java a memory leak occurs when objects in memory are not released even though the application itself no longer needs them. A common example is unused event listeners that aren't removed from their event source.

If the program keeps adding new listener objects but never gets rid of those that are no longer used, we will end up with potentially lots of memory waste. The GC won't be able to regain such memory because the unused listeners are still referenced. If these objects keep piling up we will see a progressive performance degradation which may end up in a JVM crash.

Memory leaks are not always very obvious to find, lurking in the code for quite some time before they are spotted. In other instances the leaks can become very nasty very quickly causing major spikes in the memory usage and ultimately the death of the process.
Source: http://docs2x.smartfoxserver.com/AdvancedTopics/troubleshooting-live-server#mem




回答2:


A good start would be to try and determine what all the threads are. You can use jstack (included in the JDK) to get stack dumps of all the threads which should help you discover their purpose and hopefully how to reduce their number.

jstack -l JAVA_PID > jstack.out


来源:https://stackoverflow.com/questions/39356775/threads-are-always-increasing

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