打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
HP_UNIX Java OutOfMemoryError unable to create new native thread
userphoto

2009.06.02

关注

Java中OutOfMemoryError与unable to create new native thread(JVM创建大量线程)的关系

链接:http://hi.baidu.com/hexiong/blog/item/16dc9e518fb10c2542a75b3c.html

Java中OutOfMemoryError与unable to create new native thread(JVM创建大量线程)的关系
2007年03月13日 星期二 13:14

: unable to create new native thread.这种怪事是因为JVM已经被系统分配了大量的内存(比如1.5G),并且它至少要占用可用内存的一半。有人发现,在线程个数很多的情况下,你分配给JVM的内存越多,那么,上述错误发生的可能性就越大。


那么是什么原因造成这种问题呢?

每一个32位的进程最多可以使用2G的可用内存,因为另外2G被操作系统保留。这里假设使用1.5G给JVM,那么还余下500M可用内存。这500M内存中的一部分必须用于系统dll的加载,那么真正剩下的也许只有400M,现在关键的地方出现了:当你使用Java创建一个线程,在JVM的内存里也会创建一个Thread对象,但是同时也会在操作系统里创建一个真正的物理线程(参考JVM规范),操作系统会在余下的400兆内存里创建这个物理线程,而不是在JVM的1500M的内存堆里创建。在jdk1.4里头,默认的栈大小是256KB,但是在jdk1.5里头,默认的栈大小为1M每线程,因此,在余下400M的可用内存里边我们最多也只能创建400个可用线程。

这样结论就出来了,要想创建更多的线程,你必须减少分配给JVM的最大内存。还有一种做法是让JVM宿主在你的JNI代码里边。

给出一个有关能够创建线程的最大个数的估算公式:

(MaxProcessMemory - JVMMemory - ReservedOsMemory) / (ThreadStackSize) = Number of threads

对于jdk1.5而言,假设操作系统保留120M内存:
1.5GB JVM: (2GB-1.5Gb-120MB)/(1MB) = ~380 threads
1.0GB JVM: (2GB-1.0Gb-120MB)/(1MB) = ~880 threads

对于栈大小为256KB的jdk1.4而言,
1.5GB allocated to JVM: ~1520 threads
1.0GB allocated to JVM: ~3520 threads

如果我没有记错的话,在2000/XP/2003里头有一个启动选项,好像是:/PAE /3G ,可以让用户进程最大内存扩充至3G,这时操作系统只能占用最多1G的虚存。那样应该可以让JVM创建更多的线程。

 

 

链接:http://dev2dev.bea.com.cn/bbs/thread.jspa?forumID=81&threadID=1608

 

另外确定你的HP-UX的补丁,WEBLOGIC7 SP4的补丁包需要操作系统的补丁支持,SP4推荐使用的JDK版本是JDK1.3.1_09这个在SP4补丁打完后,在WEBLOGIC的安装目录内就用。
操作系统的参数设置与你报的错误没有直接关系,错误的原因主要是你的WEBLOGIC配置,楼上各位已经说了,设置启动JVM参数,如果还有问题,就是确定你的JDK或者是WEBLOGIC的补丁是否安装了
General Information
To download supported releases for this platform, see Distribution and Installation Information.
For general information about HP-UX, see the Hewlett-Packard website.
The HP-UX 11.0 default value for maximum threads per process is 64, which may be too low for the WebLogic Server and many Java server applications in general. When the value is too low, your WebLogic Server may have problems starting up.
We recommend that you use the maximum kernel setting for the max_thread_proc and maxusers parameters. Setting maxusers to a higher value increases other machine-wide limits, such as nkthread (the maximum number of kernel threads). For example, we have reconfigured our kernel as follows:

Table 2-1 Recommended HP-UX 11.0 Kernel Settings
Parameter
Old Value
New Value
Description

max_thread_proc
64
1024
Maximum threads per process

maxfiles
60
256
Soft file limit per process

maxusers
32
256
Influences other parameters

nkthread
499
3635
Number of threads total on the system

nproc
276
2068
Maximum number of processes

ncallout
292
2084
Number of pending timeouts


WebLogic 7.0 SP4
Operating System
HP-UX 11.0 and 11i



Required OS Patches
HP-UX patches for JavaTM, see http://www.hp.com/products1/unix/java/patches/index.html



CPU
PA-RISC 100MHz or higher



RAM
512 MB minimum



Disk Space
180 MB



Supported Client JVM
HP-UX SDK 1.3.1.09
with Java HotSpotTM Server VM, dated April 18, 2003 or later



Supported Server JVM
HP-UX SDK 1.3.1.09
with Java HotSpotTM Server VM, dated April 18, 2003 or later



Performance Pack
Included.



Node Manager
Included.



Oracle jDriver
For this Oracle Server version:

Oracle 8.1.7
These Oracle jDriver shared libraries are supported:

lib/hpux11/oci817_8/libweblogicoci38.sl

lib/hpux11/oci817_8/libweblogicoxa38.sl

Oracle 9.0.1
lib/hpux11/oci901_8/libweblogicoci38.sl

lib/hpux11/oci901_8/libweblogicoxa38.sl

Oracle 9.2.0
lib/hpux11/oci920_8/libweblogic38.sl
lib/hpux11/oci920_8/libweblogicoca38.sl

NSAPI Plug-ins
For this plugin:

iPlanet 4.1
This shared library is supported:

lib/hpux11/libproxy.sl

Sun One 6.0
lib/hpux11/libproxy.sl

Apache Plug-ins
For this Apache version:

HP Apache 2.0.45
These shared libraries are supported:

lib/hpux11/mod_wl_20.so

 

链接:http://cszhzleo.spaces.live.com/blog/cns!452DDB531E252FF0!203.entry

HP unix 11.0 双机集群
一台WebLogic启动时,报错OutOfMemoryError: unable to create new native thread;而另一台正常。
经过分析为系统开发线程数太少,需要修改HP-UNIX内核参数
sam
kerneal configuration
maxusers 改为400
max_thread_proc 改为1024
退出 重新编译内核
shutdown -ry 0

HP的工程师太马虎了,就做了一台机器。唉......

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
resin的JVM參數調整
常见的 OOM 异常分析(硬核干货)
剥下“java.lang.OutOfMemoryError: unable to create new native thread”的外衣
某团面试题:JVM 堆内存溢出后,其他线程是否可继续工作?
解决 - java.lang.OutOfMemoryError: unable to create new native thread
Java程序员必备:常见OOM异常分析
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服