由于并发用户较多,且程序比较复杂,在服务器运行一段时间之后就会出现
java.lang.OutOfMemoryError:unable to create new native thread
的提示。
服务器是2G内存,我看了一下服务器内存的使用情况很好啊,只有几百M使用了,高手帮忙解决下啊

解决方案 »

  1.   

    1, Check your program memory leaks.
    2, Increase JVM heap memory may help a bit.
      

  2.   

    主要问题是程序方面的问题呢还是jvm设置的问题?
    可以通过对web服务器的设置(resin3)改善情况吗?
    另外,如果某些程序对数据库操作完毕之后没有close链接,会不会造成影响?
      

  3.   

    1.首先根据应用来看,如果它确实需要用到1G内存.你只给它500M,它一定出错.可以通过调整JVM参数来改变.
    2.程序的问题.慢慢找吧..
      

  4.   

    2G的内存应该够的,至于造成
    java.lang.OutOfMemoryError:unable to create new native thread
    我想应该是你没有把多余的进程destory掉的缘故。
    以下是一些解决方法,仅供参考
    Solution 
    There are a few things to do if you encounter this exception. 
    Use the lsof -p PID command (Unix?platforms) to see how many threads are active for this process.
    Determine if there is a maximum number of threads per process defined by the operating system. If the limit is too low for the application, try raising the per-process thread limit.
    Examine the application code to determine if there is code that is creating threads or connections (such as LDAP connections) and not destroying them. You could dump the Java?threads to see if there are an excessive number has been created.If you find that too many connections are opened by the application, make sure that any thread that the application creates is destroyed. An enterprise application (.ear) or Web application (.war) runs under a long-running JVM? Just because the application is finished does not mean that the JVM process ends. It is imperative that an application free any resources that it allocates. Another solution would be for the application to use a thread pool to manage the threads needed.
     
     
     
     
     
      

  5.   

    真搞不懂.."2G的内存应该够的"之类的.你服务器再有10G内存.你给你的应用只分配100M,它还能正常工作吗?
    你甚至都没有先搞清楚这些问题..
      

  6.   

    多数情况都是程序问题,如果用tomcat,最好还是用tomcat6,改进过了
      

  7.   

    可能有以下的原因
    1.程序出现错误,找服务器的log看看
    2.用了太复杂的查询,要优化查询语句
    3.查出了海量的数据,加些限制条件控制数据
      

  8.   

     我是resin-3.1.3,resin.conf
    <jvm-arg>-Xmx1024m</jvm-arg>
          <jvm-arg>-Xss36m</jvm-arg>
          <jvm-arg>-Xmn184m</jvm-arg>
          <jvm-arg>-Xdebug</jvm-arg>
          <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>ps -ef |grep java
    httpd    12501     1  7 20:22 pts/0    00:00:20 /usr/local/jdk1.5.0/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/resin3.1.3/ -Dresin.root=/usr/local/resin3.1.3/ -Xss256k -Xmx32m -Dcom.sun.management.jmxremote com.caucho.boot.ResinWatchdogManager start
    httpd    12535 12501 83 20:22 pts/0    00:03:47 /usr/local/jdk1.5.0/bin/java -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.awt.headless=true -Dresin.home=/usr/local/resin3.1.3/ -Xmx1024m -Xss36m -Xmn184m -Xdebug -Dcom.sun.management.jmxremote com.caucho.server.resin.Resin -socketwait 55547 start不明白为啥第一行的还是只有-Xss256k -Xmx32m 
      

  9.   

    第一行是WatchDog~ 第二个才是resin的嘛。