在哪里可以找到 Oracle JVM 的默认 -Xss(堆栈大小)值?

2022-01-16 00:00:00 jvm size stack java

有没有人找到一个 JVM 文档,其中列出了 Oracle JVM 不同版本和不同操作系统的默认 -Xss 值?

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

我已经能够在 jrockit docs,但这对那些使用普通"的人没有帮助.Oracle JVM.

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

我很欣赏 -Xss 值会因操作系统(和 JVM 版本)而异,因此可能没有一个文档列出所有最近的组合.但是,如果这里有任何读者知道任何单独的文档至少列出了 each JVM 版本(或至少 1.6 和 1.5)的默认 -Xss 值,或者即使仅适用于 一些 操作系统,这将是一个很好的开始.我对 Windows 的默认设置特别感兴趣.

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.

我要补充一点,这是有价值的原因是我们经常看到人们建议(我认为是错误的)有人可以通过更改 -Xss 值来解决问题.但是,如果您不知道您的默认值,那么就无法知道您是通过某人推荐的任何更改来提高还是降低价值.他们通常不会指出他们正在使用的版本/操作系统,所以他们的建议是否会帮助"是一个废话.你.

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.

甚至比一些文档更好,如果有人知道查询 JVM 以获取当前值的方法,无论是从命令行还是通过 API 调用,那将更有价值.谢谢.

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.

更新:我添加了我自己的答案,它总结了各种建议并指出了当前资源(2021 年初)指出答案,包括我对 -Xss 值的了解在 Windows 中.

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.

推荐答案

2011 年首次发布这个问题的答案是多么漫长而奇怪的旅程——从那以后的几年里得到了各种各样的答案.一些人建议使用 -XX:+PrintFlagsFinal JVM 参数,这对大多数人来说可能是最好的,但它对 Windows 没有帮助(总是报告 0).有些人共享了各种资源(针对各种 JVM 和版本),其中一些确实试图帮助回答这个问题,但通常没有,或者没有为那些可能在 Windows 上运行 Oracle JVM 的人澄清.

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.

这里至少更清楚一点:Java 11 是(2021 年)Oracle JVM 的当前最新 LTS(长期支持版本)版本,我找到了该当前版本的文档,其中列出了XSS(又名 ThreadStackSize)和不同操作系统的特定默认值.它位于 https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-3B1CE181-CD30-4178-9602-230B800D4FAE.以下是它报告的内容(以防将来链接中断):

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 位):1024 KB
  • macOS(64 位):1024 KB
  • Oracle Solaris/x64(64 位):1024 KB
  • Windows:默认值取决于虚拟内存

遗憾的是,Windows 用户仍然想知道:取决于虚拟内存"这意味着什么?我想这当然是指 Windows 本身的虚拟内存,但即便如此,我们如何将其转换为我们应该期望的 jvm 线程的实际堆栈大小?

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?

回到我最初的问题:我想知道 default 是什么,因为经常有人会建议解决某些问题的方法是更改​​ -XSS jvm arg(他们会提出一些价值).但是我们怎么知道我们是让它比默认值更大还是更小呢?根据要解决的问题,了解这一点至关重要!

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!

10年后,我猜这是一个可能无法完成的神话任务.但是谁知道呢,也许现在或将来有人看到这个可能会带着新信息来救援.或者 Java 17(预期的下一个 LTS 版本)可能会改变一些事情.(需要说明的是,在我写的时候,我分享的那个页面没有 Java 13 或更高版本的版本.)

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.)

如果没有别的,我把这个留给后代,至少帮助其他面临这个问题的人知道他们并不疯狂地发现很难得到一个直接的答案(尤其是关于 Windows 的默认 XSS 值,以及更改它是否会提高或降低相对于默认值的大小).

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).

相关文章