There is a JVM option configurable with -Xss which lets you adjust the maximum stack size.
First of all some background about the Stack Size
The behaviour of each JVM in relation to the Stack Size can be different: some Java Virtual Machines(JVM) put Java stack(Java method calls) and native stack(Native method calls in VM) into one stack, and perform stack unwinding using a Managed to Native Frame, known as M2NFrame. Some JVMs keep two stacks separately. The
Xss set the size of the Java Stack in most cases.
When a method of a Class is called, a new stack frame will be created on the stack of that thread. The stack will contain local variables, parameters, return address, etc. In java, you can never put an object on stack, only object reference can be stored on stack. Since array is also an object in java, arrays are also not stored on stack. So, you can reduce the space in the Thread stack by grouping some local primitive variables or parameters by grouping into objects, you can reduce the space on stack.
The reverse side of the coin, is that not being able to put Java objects into the Stack affects the performance somehow (causing a cache miss).
So, how so we set the Thread Stack size with JBoss AS or WildFly ?
In Standalone mode, just open the standalone.conf file and include the Stack Size you want to use in the JAVA_OPTS:
JAVA_OPTS="-Xms2048m -Xmx2048m -Xss228k -XX:+UseCompressedOops -XX:+UseParallelGC -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true"
In Domain mode, you can define JVM settings on a host controller, and apply those settings to server groups or individual servers. For example, here is how to apply JVM settings to one host named "host1":
/host=host1/jvm=myjvm:add( heap-size=2048m, max-heap-size=2048m, max-permgen-size=512m, stack-size=1024k, jvm-options=["-XX:-UseParallelGC"] )
Finally, consider that the minimum value that you can set on JBoss / WildFly for the Thread Stack size is -Xss228k