Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the maximum stack size limit?

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?

like image 629
Klingon Avatar asked Sep 20 '11 15:09

Klingon


People also ask

How do you calculate Max stack size?

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.

Does stack have max size?

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.

What is the maximum depth of the stack?

By default, the stack depth is set to three frames. The maximum depth that can be entered is 30 frames.

What is Max stack size in Java?

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.


1 Answers

Use ManagementFactory.getRuntimeMXBean().getInputArguments() to access all arguments passed to VM.

like image 158
AlexR Avatar answered Sep 28 '22 20:09

AlexR