java 1.5 是否有默认的 -Xmx 设置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3428251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a default -Xmx setting for java 1.5?
提问by JavaRocky
Out of interest - Does a default exist or is it different on each OS?
出于兴趣 - 是否存在默认值或每个操作系统上的默认值不同?
If it does, what are the defaults? Incredibly hard to find!
如果是,默认值是什么?难以置信的难找!
采纳答案by Matt Solnit
You can find the details in the Java 5.0 Ergonomics documentation. Specifically:
您可以在Java 5.0 Ergonomics 文档中找到详细信息。具体来说:
- For a "server class" machine (2+ processors, 2+ GB RAM), the default maximum heap size is ? of physical memory, up to 1Gbyte
- For a "regular" machine, it's 64 MB.
- 对于“服务器类”机器(2+ 个处理器,2+ GB RAM),默认的最大堆大小是?物理内存,最大 1Gbyte
- 对于“常规”机器,它是 64 MB。
回答by krock
According to java documentation the default for the Sun/Oracle Windowsand Solaris/LinuxJVMs are 64MB. This could be different for different JVM vendors though. For example, the default -Xmx value for JRockitis the lesser of 75% of the total amount of memory or 1GB.
根据 java 文档,Sun/Oracle Windows和Solaris/LinuxJVM的默认值是 64MB。不过,对于不同的 JVM 供应商,这可能会有所不同。例如,JRockit的默认 -Xmx 值是总内存量的 75% 或 1GB 中的较小者。
If you are curious about what maximum amount of memory you can use on your JVM, at runtime you can call:
如果您对可以在 JVM 上使用的最大内存量感到好奇,可以在运行时调用:
System.out.println(Runtime.getRuntime().maxMemory());
回答by Mark Booth
As Matt Solnitanswered, the specifics for java 1.5 were 1GB or ? of physical memory, whichever is lower, for a server classmachine and 64MB for other machines (from Java 5.0 Ergonomics documentation).
正如马特·索尔尼特 (Matt Solnit) 所回答的,java 1.5 的具体信息是 1GB 还是 ? 物理内存,以较低者为准,用于服务器类机器,64MB 用于其他机器(来自Java 5.0 Ergonomics 文档)。
Unfortunately JVMs change over time and the most appropriate documentation gets more difficult to identify, so to find out the default heap (and PermGen heap) size for your specific JVM, the best way to find out is to get your JVM to tell you.
不幸的是,JVM 会随着时间的推移而变化,最合适的文档变得更加难以识别,因此要找出特定 JVM 的默认堆(和 PermGen 堆)大小,最好的方法是让您的 JVM 告诉您。
Somewhere between "1.6.0_06" and "1.6.0_21", the -XX:+PrintFlagsFinal
option was added, and it appears to have first come to peoples attentionat around "1.6.0_23". It provides a wealth of information about how the JVM is configured, but we will concentrate on heap and permgen sizes and limits.
在“1.6.0_06”和“1.6.0_21”之间的某个地方,-XX:+PrintFlagsFinal
添加了该选项,它似乎在“1.6.0_23”左右首次引起人们的注意。它提供了大量关于 JVM 是如何配置的信息,但我们将专注于堆和永久代的大小和限制。
Linux
Linux
On Linux you can use the command:
在 Linux 上,您可以使用以下命令:
java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
Windows
视窗
Similarly on windows, you can use the command:
同样在 Windows 上,您可以使用以下命令:
java -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version"
Notes
笔记
- Depending on your system,
java
may default to either-client
or-server
, so if you force your application to start with either of these, you can also do the same when you start these commands.
- 根据您的系统,
java
可能默认为-client
或-server
,因此如果您强制您的应用程序以其中任何一个启动,您也可以在启动这些命令时执行相同的操作。
Examples
例子
On my Linux system, I get:
在我的 Linux 系统上,我得到:
$ java -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
uintx AdaptivePermSizeWeight = 20 {product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx InitialHeapSize := 66328448 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 1063256064 {product}
uintx MaxPermSize = 67108864 {pd product}
uintx PermSize = 16777216 {pd product}
java version "1.6.0_24"
and it defaults to -server
, so with -client
I get:
它默认为-server
,所以-client
我得到:
$ java -client -XX:+PrintFlagsFinal -version 2>&1 | grep -i -E 'heapsize|permsize|version'
uintx AdaptivePermSizeWeight = 20 {product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx InitialHeapSize := 16777216 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 268435456 {product}
uintx MaxPermSize = 67108864 {pd product}
uintx PermSize = 12582912 {pd product}
java version "1.6.0_24"
On my Windows system, I get:
在我的 Windows 系统上,我得到:
C:\>java -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version"
uintx AdaptivePermSizeWeight = 20 {product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx InitialHeapSize := 16777216 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 268435456 {product}
uintx MaxPermSize = 67108864 {pd product}
uintx PermSize = 12582912 {pd product}
java version "1.6.0_21"
which are the -client
settings and there appears to be no -server
option:
这是-client
设置,似乎没有-server
选项:
C:\>java -server -XX:+PrintFlagsFinal -version 2>&1 | findstr /I "heapsize permsize version"
C:\>java -server -XX:+PrintFlagsFinal -version
Error: no `server' JVM at `C:\jdk\jre\bin\server\jvm.dll'.
To summarise:
总结一下:
Parameter \ JVM 1.6.0_24
Lin/svr Lin/cli Windows
InitialHeapSize 63MB 16MB 16MB
LargePageHeapSizeThreshold 128MB 128MB 128MB
MaxHeapSize 1014MB 256MB 256MB
MaxPermSize 64MB 64MB 64MB
PermSize 16MB 12MB 12MB