S
Stig Christiansen
Hi all,
I must be missing something obvious, but I really have a problem with
(small) threads using virtual memory. I've read people saying that
more than 1000 threads is possible in java, but when I run this
(simple) code:
public class tst implements Runnable
{
public static void main(String args[])
{
for (int g = 0 ; g < 1000 ; g++)
{
Thread t1 = new Thread(new tst()) ;
System.out.println("x: " + g) ;
t1.start() ;
}
}
public void run()
{
System.out.println("t.1") ;
}
}
I get max 280 threads before getting a "out of memory" error:
Exception in thread "main" java.lang.OutOfMemoryError: unable to
create new native thread
at java.lang.Thread.start(Native Method)
at tst.main(tst.java:10)
At that time, the program has used 3GB of virtual memory - why??
I've tried setting the -Xss and -Xms command line options and they do
have an influence, but I still get 280 threads max.
My OS is: Linux onc-dl-1 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003
i686 i686 i386 GNU/Linux
and I'm using:
java version "1.3.1_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_13-b03)
Java HotSpot(TM) Client VM (build 1.3.1_13-b03, mixed mode)
from Sun.
Does anyone know what I'm missing here? As I see it, the problem must
be the virtual memory usage, but how can I influence this? Do I need
to look at some OS settings?
Any help will be greatly appreciated
Thanks
Stig Christiansen
I must be missing something obvious, but I really have a problem with
(small) threads using virtual memory. I've read people saying that
more than 1000 threads is possible in java, but when I run this
(simple) code:
public class tst implements Runnable
{
public static void main(String args[])
{
for (int g = 0 ; g < 1000 ; g++)
{
Thread t1 = new Thread(new tst()) ;
System.out.println("x: " + g) ;
t1.start() ;
}
}
public void run()
{
System.out.println("t.1") ;
}
}
I get max 280 threads before getting a "out of memory" error:
Exception in thread "main" java.lang.OutOfMemoryError: unable to
create new native thread
at java.lang.Thread.start(Native Method)
at tst.main(tst.java:10)
At that time, the program has used 3GB of virtual memory - why??
I've tried setting the -Xss and -Xms command line options and they do
have an influence, but I still get 280 threads max.
My OS is: Linux onc-dl-1 2.4.21-4.EL #1 Fri Oct 3 18:13:58 EDT 2003
i686 i686 i386 GNU/Linux
and I'm using:
java version "1.3.1_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_13-b03)
Java HotSpot(TM) Client VM (build 1.3.1_13-b03, mixed mode)
from Sun.
Does anyone know what I'm missing here? As I see it, the problem must
be the virtual memory usage, but how can I influence this? Do I need
to look at some OS settings?
Any help will be greatly appreciated
Thanks
Stig Christiansen