Re: maximum Thread count depends on max. heap size ?
Jul 19, 2005 6:19 AM
(reply 2
of 8) (In reply to
#1 )
The purpose of my posting was to find a explanation of the behaviour of having less threads available with more maximum heap. I cannot see why this is a limitation of virtual memory space?
Having only 500 Threads available with a 4 processor server with 4GB memory is not enough for us (only 2GB is available for the java vm)
Re: maximum Thread count depends on max. heap size ?
Jul 20, 2005 2:18 AM
(reply 3
of 8) (In reply to
#2 )
This is hardware limitation. We can't just override it. Memory allocated for managed heap inside JVM can't be used as thread stack space. So increasing one number will reduce the other.
(Managed Heap native heap thread stack size * number of threads) couldn't exceed 2 GB on 32bit x86 systems.
Well you must not be surprised by this...
JVM manages memory in a specific way and heap is not a place to get memory for threads stack.
With 32-bit platform you are limited by OS inability to address more then 4Gb memory fragment for JVM. It's NOT 2Gb as many other resources says and there is NO direct limitation in JVM code.
I can say this for sure b/c i checking it by myself and have JVM 1.5.0 update 06 running on Linux 2.6.9 smp with the following options:
#-XX:+UseBiasedLocking #Only works with 6.0 - 5.0 crashes with this
-XX:+UseSuspendResumeThreadLists
-XX:+UseLWPSynchronization
-XX:ParallelGCThreads=8
-XX:SurvivorRatio=8
-XX:TargetSurvivorRatio=90
-XX:MaxTenuringThreshold=15
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:GCHeapFreeLimit=10
-XX:+UseLargePages
-Xms2400m
-Xmx2400m
-Xmn1500m
-Xss128k
-XX:MaxPermSize=256m
-XX:PermSize=128m
It took days to figure out how to adjust my linux kernel, sysctl and bash settings. I had (of course!) recompile standard RedHat kernel. Finally it works fine and my only problem is a small swap partition i need to expand in the nearest future.
Here is a brief list of what to check in your system settings before you'll be able to run JVM with the options listed above:
ulimit--------------
data seg size (kbytes, -d) unlimited
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 206129
stack size (kbytes, -s) 2048 #This ALSO affects -Xss !!!
max user processes (-u) 16379
virtual memory (kbytes, -v) unlimited
When i try this with 1.4.2_07 on Linux 2.4 kernel, after creating 1423 threads the JVM goes into a defunct state with the following error:
Fatal: Stack size too small. Use 'java -Xss' to increase default stack size
This is independant of the Xss and Xmx settings which do not seem to make any difference.
Re: maximum Thread count depends on max. heap size ?
Nov 7, 2006 12:38 AM
(reply 8
of 8) (In reply to
#7 )
It's quite obvious - 128k is enough for stack in my configuration as i do not use TLAB and the code itself designed to use thread local carefully. IMO your system just step over the limit of 128k for statck size.
In order to fix this you may need to increase -Xss128k to be like -Xss512k