Re: Java 613 Threads limit: unable to create new native thread
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
First of all: What error message do you get? How much memory do you have
in the system? What is the output of uname -a on your system?
On my system, this program easily goes to 10000, although it demands a
lot of memory. You may want to specify a lower stack size, like this:
java -Xss150k DieLikeADog
Also, make sure you have sufficient memory available, basically the
number of threads * memory required for an empty thread. Since each
thread seems to take about 100k, this boils down to at least a GiB for
10k threads. YMMV. Note that on a 32-bit architecture, you will run out
of address space long before running out of actual memory. While you
could do crazy things with fork, I *strongly* recommend you use a 64-bit
architecture.
If you plan on having a quadruple-digits number of threads, I suggest
you either rewrite your code to use threadpools or use really fast
hardware with lots of memory (say, 10GiB)..
- -- Philipp
Keyja Keyja wrote:
> Hello,
>
> I am running the following code on my debian server:
>
> public class DieLikeADog {
> private static Object s = new Object();
> private static int count = 0;
> public static void main(String[] argv){
> for(;;){
> new Thread(new Runnable(){
> public void run(){
> synchronized(s){
> count += 1;
> System.err.println("New thread #"+count);
> }
> for(;;){
> try {
> Thread.sleep(100);
> } catch (Exception e){
> System.err.println(e);
> }
> }
> }
> }).start();
> }
> }
> }
>
> I got this code here:
> http://stackoverflow.com/questions/763579/how-many-threads-can-a-java-vm-support
>
> On my server, the program crashes after 613 threads. This is not
> normal, and has to be related to my server configuration. I had the OS
> installed when I started to rent the server at http://www.nuxit.com/
> and I never messed with the configuration.
>
> Debian version: 5.0.8
> Java version: 1.6.0_26
>
> Can anyone help me please ? I was forced to put my website offline
> because of this bug. I always have this limit of 613 threads no matter
> which program I run on my debian server.
>
> Can anyone help please ?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEAREKAAYFAk7KR2EACgkQ9eq1gvr7CFya0QCgmuvhMyqwf0M3bnxSIaMYCiWq
P+sAnR8eoOQYirEeiV4bQmb4R6GdEIha
=3fyc
-----END PGP SIGNATURE-----
Reply to: