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

发布于 2024-11-07 13:27:41 字数 916 浏览 0 评论 0原文

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

我已经能够在 jrockit 文档,但这对于那些使用“普通”Oracle JVM 的人来说没有帮助。

我确实意识到 -Xss 值会因操作系统(和 JVM 版本)而异,因此也许没有一份文档列出了所有最新组合。但是,如果这里的读者知道有任何单独的文档至少列出了每个 JVM 版本(或至少 1.6 和 1.5)的默认 -Xss 值,或者即使仅对于某些操作系统来说,这将是一个很好的开始。我对 Windows 的默认设置特别感兴趣。

我要补充一点,这是有价值的,因为我们经常看到人们建议(我认为是错误的)某人可以通过更改 -Xss 值来解决问题。但是,如果您不知道默认值,则无法知道您是否通过某人建议的任何更改来提高或降低该值。他们通常不会指出他们所使用的版本/操作系统,因此他们的建议是否会“帮助”您是一个冒险。

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

不再让梦枯萎 2024-11-14 13:27:41

尝试:

java -XX:+PrintFlagsFinal -version | grep ThreadStackSize

try:

java -XX:+PrintFlagsFinal -version | grep ThreadStackSize
最后的乘客 2024-11-14 13:27:41

此信息现在出现在 Oracle Hotspot 常见问题解答中
http://www.oracle.com/technetwork/java/hotspotfaq-138619 .html#threads_oom

您可能会遇到线程默认堆栈大小的问题。在 Java SE 6 中,Sparc 上的默认值在 32 位 VM 中为 512k,在 64 位 VM 中为 1024k。在 x86 Solaris/Linux 上,32 位 VM 中为 320k,64 位 VM 中为 1024k。

在 Windows 上,默认线程堆栈大小是从二进制文件 (java.exe) 中读取的。从 Java SE 6 开始,该值在 32 位 VM 中为 320k,在 64 位 VM 中为 1024k。

您可以通过使用 -Xss 选项运行来减小堆栈大小。例如:

java-服务器-Xss64k

请注意,在某些版本的 Windows 上,操作系统可能会使用非常粗的粒度来舍入线程堆栈大小。如果请求的大小比默认大小小1K或更多,则堆栈大小向上舍入为默认大小;否则,堆栈大小将向上舍入为 1 MB 的倍数。

64k 是每个线程允许的最小堆栈空间量。

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.

稍尽春風 2024-11-14 13:27:41

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

这里至少更清楚一点: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。以下是它的报告内容(以防将来链接中断):

  • Linux/x64(64 位):1024 KB
  • macOS(64 位):1024 KB
  • Oracle Solaris/x64(64 位):1024 KB
  • Windows:默认值取决于虚拟内存

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

回到我最初的问题:我想知道默认是什么,因为经常有人建议解决某些问题的方法是更改​​-XSS jvm arg(他们建议的某个值)。但是我们如何知道我们是否将其设置为大于或小于默认值呢?根据要解决的问题,了解这一点至关重要!

10年后,我想这是一个可能无法完成的神话般的探索。但谁知道呢,也许现在或将来看到这一点的人可能会带着新信息前来救援。也许 Java 17(预期的下一个 LTS 版本)可能会改变一些事情。 (需要明确的是,正如我所写,我共享的该页面没有针对 Java 13 或更高版本的版本。)

如果没有别的事情,我将其留给后人,至少可以帮助其他面临此问题的人知道他们“我并不疯狂地发现很难得到一个直接的答案(特别是关于 Windows 的默认 XSS 值,以及更改它是否会相对于默认值增大或减小大小)。

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

指尖上的星空 2024-11-14 13:27:41

您可以在Oracle 站点的“”下找到它-XX:ThreadStackSize”选项,其含义与-Xss相同。

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

风筝有风,海豚有海 2024-11-14 13:27:41

对于热点,这取决于您的架构以及其他什么。

默认堆栈大小可以在与给定平台相关的头文件的源代码中找到,例如

Google 代码搜索 (编辑:遗憾的是,自从做出此答案以来,此服务已被停用)
更新:这是 Nebelmann 的新链接: Openjdk源码: globals_windows_x86.hpp

不确定这是否有帮助,但它是一个开始

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

允世 2024-11-14 13:27:41

IBM Java 6 用户指南 ():

Xss(适用于 Java 线程 32 位):

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文