Re: Max number of threads with NPTL
Hui Huang <[email protected]>
| Newsgroups | gmane.comp.java.linux.general |
|---|---|
| Message-ID | <[email protected]> |
Nathan Bryant wrote:
> 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,
Default stack size is 512k. You need 3500 * 512k = 1750M address space
for 3500 threads. Try -Xss96k. Also check your limit on max #processes
(ulimit -u), you can't create more threads than that limit either.
regards,
-hui
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]
>
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]