jWebSocket java.lang.OutOfMemoryError:无法创建新的本机线程

时间:2021-11-16 17:34:36

I'm trying to run jWebSocket server on CentOS 5.8 (1and1 VPS). Just after start of the server and few requests from client (reloading webpage) I get this error:

我正在尝试在CentOS 5.8(1和1 VPS)上运行jWebSocket服务器。刚刚启动服务器和客户端的几个请求(重新加载网页)后,我收到此错误:

Exception in thread "jWebSocket TCP-Connector 01.33719.16" java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:691)
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
        at java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1555)
        at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:333)
        at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:546)
        at java.util.concurrent.ScheduledThreadPoolExecutor.submit(ScheduledThreadPoolExecutor.java:646)
        at org.jwebsocket.tcp.TimeoutOutputStreamNIOWriter.sendPacket(TimeoutOutputStreamNIOWriter.java:215)
        at org.jwebsocket.tcp.TCPConnector.sendPacket(TCPConnector.java:279)
        at org.jwebsocket.server.BaseServer.sendPacket(BaseServer.java:186)
        at org.jwebsocket.server.TokenServer.sendPacketData(TokenServer.java:405)
        at org.jwebsocket.server.TokenServer.sendTokenData(TokenServer.java:388)
        at org.jwebsocket.server.TokenServer.sendToken(TokenServer.java:312)
        at org.jwebsocket.plugins.TokenPlugIn.sendToken(TokenPlugIn.java:174)
        at org.jwebsocket.plugins.system.SystemPlugIn.sendWelcome(SystemPlugIn.java:397)
        at org.jwebsocket.plugins.system.SystemPlugIn.connectorStarted(SystemPlugIn.java:261)
        at org.jwebsocket.plugins.BasePlugInChain.connectorStarted(BasePlugInChain.java:126)
        at org.jwebsocket.server.TokenServer.connectorStarted(TokenServer.java:170)
        at org.jwebsocket.engines.BaseEngine.connectorStarted(BaseEngine.java:93)
        at org.jwebsocket.tcp.TCPEngine.connectorStarted(TCPEngine.java:320)
        at org.jwebsocket.tcp.TCPConnector$ClientProcessor.run(TCPConnector.java:502)
        at java.lang.Thread.run(Thread.java:722)

But when I run jWebSocket on my computer everything is working ok. I made my own virtual server using virtualbox and CentOS 5.8 fresh install and it is working there too.

但是当我在我的电脑上运行jWebSocket时,一切正常。我使用virtualbox和CentOS 5.8全新安装制作了自己的虚拟服务器,它也在那里工作。

I noticed that java on 1and1 VPS uses a lot of memory ~1GB (10 times more then on my computer or virtualbox). On 1and1 VPS I have 2GB of RAM (there is an error) and on Virtualbox jWebSocket is running just fine with only 512MB of RAM.

我注意到1和1 VPS上的java使用了大量内存~1GB(比我的计算机或虚拟机上多10倍)。在1和1 VPS上,我有2GB的RAM(有一个错误),在Virtualbox上,jWebSocket运行正常,只有512MB的RAM。

What may be the cause of this out of memory error? Please share if you have any suggestions. I don't know what to do with this any more.

导致内存不足错误的原因是什么?如果您有任何建议,请分享。我不知道该怎么办了。

2 个解决方案

#1


0  

check the link: http://devgrok.blogspot.sk/2012/03/resolving-outofmemoryerror-unable-to.html
sounds like they had to increase in linux max process per user limit.
At least the similarity with your problem I see is that you get the same exception + both run linux :)

检查链接:http://devgrok.blogspot.sk/2012/03/resolving-outofmemoryerror-unable-to.html听起来他们必须增加每个用户限制的linux max进程。至少与我遇到的问题的相似之处在于你得到了同样的异常+两个运行linux :)

#2


0  

It is 1and1 (http://www.1and1.pl/) virtual hosting problem. They use Parallels Virtuozzo Containers with so called User Beancounters or UBC parameters. It is a set of limits witch was the cause of my problems. You can see this limits in /proc/user_beancounters. When one of the limits called "numproc" is reached my application can't create new threads.

这是1and1(http://www.1and1.pl/)虚拟主机问题。他们使用Parallels Virtuozzo Containers和所谓的User Beancounters或UBC参数。这是一系列限制女巫是我的问题的原因。您可以在/ proc / user_beancounters中看到此限制。当达到一个名为“numproc”的限制时,我的应用程序无法创建新线程。

EDIT

At that time jWebSocket was designed in way that it was creating one thread for every incoming token and not destroying it when this thread was no more needed.

那时jWebSocket的设计方式是为每个传入的令牌创建一个线程,而不再需要此线程时将其销毁。

I'm not using jWebSocket any more, I replaced it with websocket serwer written in PHP.

我不再使用jWebSocket了,我用用PHP编写的websocket serwer替换它。

#1


0  

check the link: http://devgrok.blogspot.sk/2012/03/resolving-outofmemoryerror-unable-to.html
sounds like they had to increase in linux max process per user limit.
At least the similarity with your problem I see is that you get the same exception + both run linux :)

检查链接:http://devgrok.blogspot.sk/2012/03/resolving-outofmemoryerror-unable-to.html听起来他们必须增加每个用户限制的linux max进程。至少与我遇到的问题的相似之处在于你得到了同样的异常+两个运行linux :)

#2


0  

It is 1and1 (http://www.1and1.pl/) virtual hosting problem. They use Parallels Virtuozzo Containers with so called User Beancounters or UBC parameters. It is a set of limits witch was the cause of my problems. You can see this limits in /proc/user_beancounters. When one of the limits called "numproc" is reached my application can't create new threads.

这是1and1(http://www.1and1.pl/)虚拟主机问题。他们使用Parallels Virtuozzo Containers和所谓的User Beancounters或UBC参数。这是一系列限制女巫是我的问题的原因。您可以在/ proc / user_beancounters中看到此限制。当达到一个名为“numproc”的限制时,我的应用程序无法创建新线程。

EDIT

At that time jWebSocket was designed in way that it was creating one thread for every incoming token and not destroying it when this thread was no more needed.

那时jWebSocket的设计方式是为每个传入的令牌创建一个线程,而不再需要此线程时将其销毁。

I'm not using jWebSocket any more, I replaced it with websocket serwer written in PHP.

我不再使用jWebSocket了,我用用PHP编写的websocket serwer替换它。