Where can I find default -Xss (stack size) value for Oracle JVM?

JavaJvmStackSize

Java Problem Overview


Has anyone ever found a single JVM document listing default -Xss values for various versions of the Oracle JVM, and for different OS's?

I've been able to find this table in the jrockit docs, but that's not helpful for those using the "normal" Oracle JVM.

I do appreciate that the -Xss value will vary per OS (and JVM version), so maybe there's no one document that lists all recent combinations. But if any readers here know of any individual documents that list at least just the default -Xss value for each JVM version (or at least 1.6 and 1.5), or even if only for some OS's, that would be a great start. I'm especially interested in the default for Windows.

I'll add that the reason this is valuable is that often we see people recommend (wrongly, I think) that someone can solve a problem by changing the -Xss value. But if you don't know your default, then there's no way to know if you're raising or lowering the value by whatever change someone recommends. They don't generally indicate the version/OS they're on, so it's a crapshoot whether their suggestion will "help" you.

Even better than some documentation, if anyone knows a way to query the JVM to get the current value, whether from the command line or via an API call, that would be even more valuable. Thanks.

> Update: I have added an answer of my own that summarizes the various suggestions and points to a current resource (in early 2021) > indicating the answer, including what I learned about the -Xss value > in Windows.

Java Solutions


Solution 1 - Java

try:

java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

Solution 2 - Java

This information now appears in the Oracle Hotspot FAQ http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#threads_oom

> You may be running into a problem with the default stack size for threads. In Java SE 6, the default on Sparc is 512k in the 32-bit VM, and 1024k in the 64-bit VM. On x86 Solaris/Linux it is 320k in the 32-bit VM and 1024k in the 64-bit VM.

> On Windows, the default thread stack size is read from the binary (java.exe). As of Java SE 6, this value is 320k in the 32-bit VM and 1024k in the 64-bit VM.

> You can reduce your stack size by running with the -Xss option. For example:

> java -server -Xss64k

> Note that on some versions of Windows, the OS may round up thread stack sizes using very coarse granularity. If the requested size is less than the default size by 1K or more, the stack size is rounded up to the default; otherwise, the stack size is rounded up to a multiple of 1 MB.

>64k is the least amount of stack space allowed per thread.

Solution 3 - Java

What a long, strange trip it's been getting to an answer to this question, first posted in 2011--and getting all kinds of answers in the years since. Some proposed using the -XX:+PrintFlagsFinal JVM argument, which may be best for most, but it did not help for Windows (always reports 0). And some folks shared various resources (for various JVMs and versions), some of which did try to help answer this question but often did not, or did not clarify for those who may be running an Oracle JVM on Windows.

Here's at least a bit more clarity: with Java 11 being (in 2021) the current latest LTS (long-term support release) version of the Oracle JVM, I've found a document for that current version which DOES list the specific defaults for XSS (aka ThreadStackSize), and for different OS's. It's at https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE. Here's what it reports (in case that link breaks in the future):

> - Linux/x64 (64-bit): 1024 KB > - macOS (64-bit): 1024 KB > - Oracle Solaris/x64 (64-bit): 1024 KB > - Windows: The default value depends on virtual memory

Sadly, Windows folks are still left to wonder: what could that mean, "depends on virtual memory"? I suppose it means the virtual memory of Windows itself of course, but even then how do we translate that into what we should expect the actual stack size for a jvm thread to be?

And back to my original question: I'd wanted to know what the default was, because so often someone might suggest the solution to some problem is to change that -XSS jvm arg (to some value they would propose). But how can we know if we are making it larger or smaller than the default? Depending on the problem being solved, that can be vital to know!

After 10 years, I guess it's a mythical quest that may not be concluded. But who knows, maybe someone seeing this now or in the future may ride to the rescue with new info. Or perhaps Java 17 (the expected next LTS version) may change things. (To be clear, there is no version of that page I shared, for Java 13 or above, as I write.)

If nothing else, I leave this for posterity, to at least help someone else facing this question to know that they're not crazy in finding it so hard to get a straight answer (especially about the default XSS value for Windows, and whether changing it would be raising or lowering the size relative to the default).

Solution 4 - Java

You can find it at Oracle site under "-XX:ThreadStackSize" option which means the same as -Xss.

Solution 5 - Java

For hotspot it depends on your architecture and what not.

The default stack size can be found in the source code in the header files that relate to a given platform e.g.

google code search (edit: this service has been deactivated since this answer was made, sadly) UPDATE: here's a new link from Nebelmann: Openjdk source: globals_windows_x86.hpp

Not sure if this helps but its a start

Solution 6 - Java

There are default settings available from IBM Java 6 user guide (source):

Xss <size> for Java Threads 32 bits:

AIX®: 256KB
IBM®I: 256KB
Linux: 256KB
Windows: 256KB
z/OS®: 256KB

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questioncharlie arehartView Question on Stackoverflow
Solution 1 - JavaplockcView Answer on Stackoverflow
Solution 2 - JavaBenView Answer on Stackoverflow
Solution 3 - Javacharlie arehartView Answer on Stackoverflow
Solution 4 - JavakeypressView Answer on Stackoverflow
Solution 5 - JavaGreg BowyerView Answer on Stackoverflow
Solution 6 - JavachepseskafView Answer on Stackoverflow