Consultor Eletrônico



Kbase P26400: How to configure max_thread_proc and avoid Java Out of Memory error on HP-UX.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/30/2008
Status: Verified

GOAL:

How to configure max_thread_proc and avoid Java Out of Memory error on HP-UX.

GOAL:

What is the max_thread_proc?

GOAL:

What is nkthread?

FACT(s) (Environment):

HP-UX
Progress/OpenEdge Product Family

FIX:

This Solution explains how to configure two HP-UX kernel parameters for JavaTMSupport so that the maximum number of threads per process is not encountered. Reaching the maximum number of threads per process is usually seen as a Java Out of Memory error.

To determine if this is the error causing the problem check the admserv.log for errors relating to the Java Out of Memory error. There should be a note in this log as to which log file will contain details about the resource error. (ie. ads0.exp )

Java programs can use threads and sockets heavily. Server applications commonly spawn one to two threads for each client connected to the server (one socket connection to read and another to write).

According to Hewlett Packard, the default values for HP-UX 11.0 are set too low for most Java applications. Two kernel parameters need to be set so that the limit of the maximum number of threads per process is not encountered.

They are max_thread_proc and nkthread.


To work around the Out of Memory error, the value of the max_thread_proc must be set higher than the expected maximum number of simultaneously active threads for the application.

The number of threads needed by the process can be checked by using the -eprof option available with JDK 1.1.8. Analyze the Java.eprof file using HPjmeter by selecting the threads metric.


For information about HPjmeter, refer to:

http://www.hp.com/products1/unix/java/hpjmeter/

max_thread_proc is the maximum number of threads allowed in each process. The minimum value (and default) is 64, and is often too low for most Java applications. The maximum value is the value of nkthread.
They appear in the kernel as:

Java Generic Server

maxusers 400
max_thread_proc maxusers*3
maxfiles 2048
maxfiles_lim 2048
ncallout 2*((((nproc*7)/4)+16)*2)
nkthread 2*max_thread_proc
nfile (2*nproc)+1000
nproc ((maxusers*5)+64)

nkthread is the total number of kernel threads available in the system. This parameter is similar to the nproc tunable except that it defines the limit for the total number of kernel threads able to run simultaneously in the system.

The value of nkthread must be greater than nproc. The default is approximately twice that of nproc. The maximum is 30000. The suggested value of nkthread is 2*max_thread_proc.

If there are a lot of Java processes running and each running process uses many threads, the value of nkthread must be increased to support the number of processes running.
(Remember, nkthread limit should be based on what the max_thread_proc is set to.)