Java 内存限制 -Xmx 后缀:大写与小写 m/M 和 g/G
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23700112/
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
Java Memory Limit -Xmx suffix: upper vs lower case m/M and g/G
提问by MinecraftShamrock
It is commonly known that it is possible to limit the Java heap size with -Xmx<amount><unit>
, where unit
is the data amount unit like Gigabyte, Megabyte, etc.
I know that -Xmx128M
means 128 Mebibytes (= 128 * 1024 * 1024 bytes).
众所周知,可以使用 来限制 Java 堆大小-Xmx<amount><unit>
,其中unit
数据量单位是千兆字节、兆字节等。我知道这-Xmx128M
意味着 128兆字节(= 128 * 1024 * 1024 字节)。
But is it true, that it is also possible to use decimal units like megabytes using -Xmx100m
(which would be 100 * 1000 * 1000 bytes)?
但是真的-Xmx100m
吗,也可以使用像兆字节这样的十进制单位(即 100 * 1000 * 1000 字节)?
So is it possible to use this decimal units by using lower-case unit suffixes like k, m, g
instead of K, M, G
?
那么是否可以通过使用小写单位后缀k, m, g
而不是K, M, G
?
采纳答案by Sanjeev
There is no difference between k and K both means kibibyte
and so does m/M = mebibyte
& g/G = gibibyte
. you can set 100m
as the value and it will be 100 * 1024 * 1024 bytes
. generally it is advised to use this value in powers of 2.
k 和 K 之间没有区别,kibibyte
m/M = mebibyte
& g/G = 也是如此gibibyte
。您可以设置100m
为值,它将是100 * 1024 * 1024 bytes
. 通常建议在powers of 2.
Hope it helps.
希望能帮助到你。
回答by apangin
Why don't you just try -Xmx100m
and -Xmx100M
and check if there is any difference.k, m, g
work exactly like K, M, G
- they all mean binary units.
你为什么不尝试-Xmx100m
并-Xmx100M
检查是否有任何区别。k, m, g
工作方式完全一样K, M, G
——它们都是二进制单位。
回答by TerekC
All memory sizes used by the JVM command line arguments are specified in binary units (Kibibyte, Mebibyte, etc.) regardless of unit capitalization; where a 'kilobyte' is 1024 bytes, and the others are increasing powers of 1024.
JVM 命令行参数使用的所有内存大小均以二进制单位(Kibibyte、Mebibyte 等)指定,而不管单位大小写;其中“千字节”为 1024 字节,其他为 1024 的递增幂。
This answergoes into a more complete technical answer to the question.
这个答案是对这个问题的更完整的技术答案。