Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do Xss option for JVM only cover the Java Stacks or also including Native Stacks?

Tags:

java

jvm

I know some Virtual Machine like Harmony JVM put Java Stack and Native Stack into one stack and perform stack unwinding using a M2N Frame for each thread.

Some other JVMs seem to put them separately. My question is do the Xss option to JVM that set the maximum stack size of JVM cover the total size of the Java stacks or also including the size of native stacks?

like image 989
StarPinkER Avatar asked Nov 17 '13 13:11

StarPinkER


People also ask

What is XSS in JVM options?

Sets the maximum stack size for Java™ threads. To increase the maximum number of threads your system can support, reduce the maximum native stack size. The default is 320 KB for 31-bit or 32-bit VMs and 1024 KB for 64-bit VMs.

What are JVM options?

JVM Options Overview There are three types of options that you can add to your JVM, standard, non-standard and advanced options. If you apply an advanced option, you always precede the option with -XX: . Similarly if you're using a non-standard option, you'll use -X .

What is JVM stack size?

The default value for the stack size in the JVM is 1024K. Therefore, you must increase the stack size for the JVM to 4M depending on the recursive logic defined in the workflow.

How many stacks are there in Java?

The Java Stack class provides mainly five methods to perform these operations. Along with this, it also provides all the methods of the Java Vector class.


1 Answers

I do not have a definitive answer to this but when you look at some of the documents released when hotspot became the default vm, you can see this, which states that:

HotSpot doesn't have separate native and Java stacks

Another anecdotal evidence could be found in this blog post that deals with stack size tuning:

Note that it is entirely possible that your OS rounds up values for stack size specified by your -Xss parameter. Watch out for that.

So it appears that hotspot has a single stack per thread that is actually the native, os-provided stack (hence the rounding).

There's some more evidence here:

In the HotSpot implementation, Java methods share stack frames with C/C++ native code, namely user native code and the virtual machine itself

and finally, in openjdk source code:

// HotSpot does not have separate native and Java stacks

like image 63
radai Avatar answered Oct 16 '22 23:10

radai