What is the difference between -Xss and -XX:ThreadStackSize?

前端 未结 5 2144
我寻月下人不归
我寻月下人不归 2021-02-13 16:00

I just want to control the stack size for all of my threads in a Java (groovy) application. For the Hotspot Oracle VM, I know that there are two parameters doing that (-Xss and

5条回答
  •  生来不讨喜
    2021-02-13 16:34

    The Oracle Java SE 8 docs suggest that -Xss and -XX:ThreadStackSize=size are equivalent. However this not correct. Try eg.

    java -XX:ThreadStackSize=1024 -version
    java version "1.8.0_171"
    Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
    
    java -Xss1024 -version
    The stack size specified is too small, Specify at least 160k
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    

    This is fixed e.g. in the Java 14 documentation:

    -XX:ThreadStackSize=size Sets the Java thread stack size (in kilobytes). Use of a scaling suffix, such as k, results in the scaling of the kilobytes value so that -XX:ThreadStackSize=1k sets the Java thread stack size to 1024*1024 bytes or 1 megabyte.

    and

    -Xss size Sets the thread stack size (in bytes).

提交回复
热议问题