I want to determine the maximum size of the stack programmatically from within Java (the size set by -Xss). How do I do this?
Alternatively, as my Java module also uses a native code module, I would be able to do this via JNI; but how?
You can call the getrlimit () function to get the current stack size. Typical maximum size of a stack is 1 MB on Widows, while on a typical modern Linux it is 8 MB, though those values can be adjusted in a number of ways.
On Windows, the typical maximum size for a stack is 1MB, whereas it is 8MB on a typical modern Linux, although those values are adjustable in various ways.
By default, the stack depth is set to three frames. The maximum depth that can be entered is 30 frames.
Default stack size varies between 320k and 1024k depending on the version of Java and the system used. For a 64 bits Java 8 program with minimal stack usage, the maximum number of nested method calls is about 7 000. Generally, we don't need more, excepted in very specific cases. One such case is recursive method calls.
Use ManagementFactory.getRuntimeMXBean().getInputArguments()
to access all arguments passed to VM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With