简体   繁体   English

有没有办法在同一服务器上运行两个JVM?

[英]There's any way to run two JVM in the same server?

I'm having some issues with the JVM; 我在JVM方面遇到了一些问题; I have a Web page and an application with no GUI(UDP server), and both uses the same database, the application(UDP server) it's working ok but if the web application get out of memory the whole JVM stop; 我有一个网页和一个没有GUI(UDP服务器)的应用程序,并且都使用相同的数据库,该应用程序(UDP服务器)可以正常工作,但是如果Web应用程序内存不足,整个JVM就会停止; so I was thinking to put the UDP server in a different JVM. 所以我在考虑将UDP服务器放在另一个JVM中。

I'm getting the following messages 我收到以下消息

May 21, 2013 5:24:05 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks 2013年5月21日下午5:24:05 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/track] created a ThreadLocal with key of type [org.opengts.util.ThreadLocalMap$1] (value [org.opengts.util.ThreadLocalMap$1@277085a4]) and a value of type [java.util.Hashtable] (value [{jdbc:mysql://localhost:3306/gts?characterEncoding=UTF-8&useUnicode=true&characterSetResults=utf8=org.opengts.dbtools.DBConnection@22236dae}]) but failed to remove it when the web application was stopped. 严重:Web应用程序[/ track]创建了一个ThreadLocal,其密钥类型为[org.opengts.util.ThreadLocalMap $ 1](值[org.opengts.util.ThreadLocalMap$1@277085a4])和一个值类型为[java.util .Hashtable](值[{jdbc:mysql:// localhost:3306 / gts?characterEncoding=UTF-8&useUnicode=true&characterSetResults=utf8=org.opengts.dbtools.DBConnection@22236dae}]),但在Web应用程序中无法删除被停止了。 Threads are going to be renewed over time to try and avoid a probable memory leak. 线程将随着时间的流逝而更新,以尝试避免可能的内存泄漏。

and when I restart the web page 当我重新启动网页时

May 21, 2013 5:24:20 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2695 ms
Exception in thread "http-bio-8080-Acceptor-0" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:657)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1336)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:176)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:156)
at org.apache.tomcat.util.net.JIoEndpoint.processSocket(JIoEndpoint.java:510)
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:229)
at java.lang.Thread.run(Thread.java:679)
Exception in thread "http-bio-8080-exec-8" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:657)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:943)
at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:992)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)

NEW INFO 新资讯

I tried the ulimit command getting the following results. 我尝试了ulimit命令,得到以下结果。

ulimit
unlimited
ulimit -Hn
163840
ulimit -n
163840
ulimit -u
1024

Now I'm wondering what's the meaning of those numbers? 现在我想知道这些数字的含义是什么? They are the amount of process or memory in MBytes? 它们是MB的进程或内存量吗?

您必须在不同的端口上运行Web服务器,所以这不是JVM问题-它是catalina的配置

The "java.lang.OutOfMemoryError: unable to create new native thread" error isn't really an out of memory error at all -- the JVM is unable to create a new thread due to an OS limitation. “ java.lang.OutOfMemoryError:无法创建新的本机线程”错误实际上根本不是内存不足错误-由于操作系统的限制,JVM无法创建新线程。

What OS are you using? 您正在使用什么操作系统? On linux, you can increase this by doing: 在linux上,您可以这样做:

ulimit -u <new limit>

Before creating new JVM I would examine Thread creation first. 在创建新的JVM之前,我将首先检查线程的创建。

I had the same problem with number of Threads limitation until I added 在添加之前,我对线程数的限制有同样的问题

executor.shutdown(); 

for ExecutorService within the finally block 在finally块中获取ExecutorService

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

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