XX 的默认值:MaxDirectMemorySize
XX:MaxDirectMemorySize 的默认值是多少?
What is the default value for XX:MaxDirectMemorySize?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
XX:MaxDirectMemorySize 的默认值是多少?
What is the default value for XX:MaxDirectMemorySize?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
来自
sun.misc.VM
,它是Runtime.getRuntime.maxMemory()
,这就是用-Xmx
配置的。例如如果您没有配置-XX:MaxDirectMemorySize
并且配置-Xmx5g
,则“默认”>MaxDirectMemorySize
也将为 5 Gb,应用程序的总堆+直接内存使用量可能会增长到 5 + 5 = 10 Gb。From
sun.misc.VM
, it'sRuntime.getRuntime.maxMemory()
, that's what is configured with-Xmx
. E. g. if you don't configure-XX:MaxDirectMemorySize
and do configure-Xmx5g
, the "default"MaxDirectMemorySize
will also be 5 Gb, and the total heap+direct memory usage of the app may grow up to 5 + 5 = 10 Gb.来自 http://www.docjar.com/html/api/ sun/misc/VM.java.html
我明白了:
所以它似乎默认为 64 兆。
From http://www.docjar.com/html/api/sun/misc/VM.java.html
i see:
so it appears to default to 64 megs.
对于JDK8:
64MB最初是任意设置的,...
(来自:https://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/sun/misc/VM.java#L186 )
...但是然后 directMemory 设置为 maxMemory() ~= Heapsize (如果未设置 maxDirectMemorySize-Parameter):
(来自: https://github.com/frohoff/jdk8u-dev-jdk/blob/master /src/share/classes/sun/misc/VM.java#L286 )
测试似乎支持这种说法,
“test.java.nio.Buffer.LimitDirectMemory.java”:(
来自 https://github.com/frohoff/jdk8u-dev-jdk/blob/da0da73ab82ed714dc5be94acd2f0d00fbdfe2e9/test/java/nio/Buffer/LimitDirectMemory.java#L74)
For JDK8:
The 64MB are set arbitrarily initially, ...
(From: https://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/sun/misc/VM.java#L186 )
... but then the directMemory is set to maxMemory() ~= Heapsize here (if the maxDirectMemorySize-Parameter is not set):
(from: https://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/sun/misc/VM.java#L286 )
The test seems to support this claim,
"test.java.nio.Buffer.LimitDirectMemory.java":
(from https://github.com/frohoff/jdk8u-dev-jdk/blob/da0da73ab82ed714dc5be94acd2f0d00fbdfe2e9/test/java/nio/Buffer/LimitDirectMemory.java#L74)