Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I increase the thread limit on Linux?

843811Apr 9 2003 — edited Apr 10 2003
OS: Linux (or Sun Linux)
Kernel: 2.4.9-31enterprise
Memory: 2GB
CPUs: 2
Java: 1.4.1_01

I have a dual processor Cobalt LX50 and I am running
into a thread limit with Java. No matter what I do
with the Java JVM parameters (heap and stack), I
cannot get any more than 949 threads. My "top" and "vmstat" output
shows that I am no where near my memory capacity.
Below is a simple Java program (28 lines long) I have
used to test this limit. My question is simply how do
I go about increasing this limit. Is there some kernel
parameter I can set or maybe have to recompile into
the kernel? My /proc/sys/kernel/threads-max is 16383.
I do not believe my ulimit settings are the problem,
but I will post them anyway. The problem also occurs
on non-Cobalt (plain old PCs) uniprocessor machines
maxxing at about 1018 threads. The other interesting thing is that when I run the same program through the Kaffe VM with -Xms64M and -Xmx512M I do not run into the thread limit problem. Does anyone know what I need to change to get my thread limit up? Also, rewriting the way the program uses threads is not an option.

[root]# ulimit -a core file size (blocks) 0
data seg size (kbytes) unlimited
file size (blocks) unlimited
max locked memory (kbytes) unlimited
max memory size (kbytes) unlimited
open files 1024
pipe size (512 bytes) 8
stack size (kbytes) 8192
cpu time (seconds) unlimited
max user processes 8191
virtual memory (kbytes) unlimited


/*******************************Sample java program
testing thread
limits***********************************************/
import java.util.Timer;
import java.util.TimerTask;


public class Reminder {
Timer timer;
static int cnt;


public Reminder(int seconds) {
timer = new Timer();
timer.schedule(new RemindTask(), seconds*1000);
}


class RemindTask extends TimerTask {
public void run() {
System.out.println("Time's up!");
timer.cancel(); //Terminate the timer thread
}
}


public static void main(String args[]) {
System.out.println("About to schedule task.");
cnt = 0;
while (true) {
new Reminder(90);
System.out.println("Thread #" + ++cnt + "
scheduled.");
}
}
}
/****************************************************************************************/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2003
Added on Apr 9 2003
1 comment
119 views