Re: Max number of threads with NPTL

Nathan Bryant <[email protected]>
Newsgroups gmane.comp.java.linux.general
Organization Allegient Systems
Message-ID <[email protected]>
Daniel Malmkvist wrote:

>To my supprise i could not have more then ~3500 threads at the same time.
>I got a OutOfMemoryException, but there was plenty of system memory left
>(the JVM only ha about 10% of system physical memory).
>  
>
Address space might be a limiting factor in a 32-bit machine. Assuming a 
3gig/1gig VM split, you have less than a megabyte per thread stack at 
3500 threads, even assuming there is no other memory overhead, and there 
is a lot of other overhead... Did you try using the Thread constructor 
that specifies a stack size? Try specifying a single page - 4K.

You might also need to increase the maximum size of the Java heap. (Or 
decrease it to make room for more stack?) I have found that it can't 
grow beyond 1.5gig on x86.

If you are allocating the default stack size which is probably fairly 
large, the system won't appear to be using the memory because the stack 
pages won't have corresponding physical pages allocated by the VM until 
they are used - the stacks grow down. But they are still allocated 
virtual address space within the process.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.