The HP-UX 11.0 default value for maximum threads per process is 64, which may be too low for WebLogic Server and many Java server applications in general. When the value is too low, WebLogic Server may have problems starting up.
BEA recommends 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). The following table provides some examples.
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报错OutOfMemoryError: unable to create new native thread时要修改以上配置参数,方法如下:
$sam
选择kerneal configuration
退出,重新编译内核
$shutdown -ry 0
Linux下open file 和max user process的设置:
新装的linux默认只有1024,当作负载较大的服务器时,很容易遇到error: too many open files。因此,需要将其改大。
使用 ulimit -n 65535 可即时修改,但重启后就无效了。(注ulimit -SHn 65535 等效 ulimit -n 65535,-S指soft,-H指hard)
有如下三种修改方式:
1.在/etc/rc.local 中增加一行 ulimit -SHn 65535
2.在/etc/profile 中增加一行 ulimit -SHn 65535
3.在/etc/security/limits.conf最后增加如下两行记录
* soft nofile 65535
* hard nofile 65535
具体使用哪种,试试哪种有效吧,我在 CentOS中使用第1种方式无效果,使用第3种方式有效果,而在Debian中使用第2种有效果,其实CentOS ulimit命令本身就有分软硬设置,加-H就是硬,加-S就是软默认显示的是软限制,如果运行CentOS ulimit命令修改的时候没有加上的话,就是两个参数一起改变.生效,修改完重新登录就可以见到.(我的系统是CentOS5.1.修改了,重新登录后就立刻生效.可以用CentOS ulimit -a 查看确认.)
ulimit -n (设置open file 数目)
ulimit -u (设置max user process)
For each new Thread created in Java, the Java VM creates a new native Thread within the operating system, in Java 1.4 the VM reserved 256k of address space per thread, with the new Java 1.5 VM
1MB is reserved per Thread. The interesting thing is that this memory per thread is NOT taken from the overall memory of the Java VM (the "Xmx-memory") but from the rest of free memory on the machine. I.e. if you have a machine with 1GB RAM and assign 800 megs to the Java VM with -Xmx800M, only 200 megs are left for the operating system AND the creation of threads.
In order to avoid this kind of error you have to REDUCE the assigned memory of the Java VM or you can reduze the amount of address space reserved per thread from 1mb down to 256k again (with some Java VM option).
即:当前操作系统的内存无法供应 JVM 创建更多的线程,可以下面方法解决问题:
- 通过设置-Xmx512m 减少JVM Heap size
- 通过设置-Xss64k 减少线程占用的Stack size
- 增加操作系统内存