Cassandra中的堆内存默认分配 [英] Heap Memory default allocation in Cassandra
问题描述
根据cassandra-env.sh,440G总RAM的默认堆内存分配应为32765M(JVM切换到64位引用之前的最大CAP).
As per cassandra-env.sh the default heap memory allocation for a 440G Total RAM should be 32765M (Maximum CAP before JVM Swithches to 64 bit reference).
所以,当我查询"java -XX:+ PrintCommandLineFlags -version"或"java -XX:+ PrintFlagsFinal -version | grep -iE'MaxHeapSize'"时,为什么显示32210157568字节(30718M)
So, why is it showing 32210157568 bytes(30718M) when I query "java -XX:+PrintCommandLineFlags -version" or "java -XX:+PrintFlagsFinal -version | grep -iE 'MaxHeapSize'"
为什么会有大约2G的差异.
Why is there difference, of around 2G.
仅供参考:jvm.options文件是默认&使用DSE 5.1.3.
推荐答案
java -XX:+PrintFlagsFinal
与Cassandra无关,而且我不知道您为什么提到cassandra-env.sh
.无论如何,让我回答问题的主要部分.
java -XX:+PrintFlagsFinal
has nothing to do with Cassandra, and I don't know why you mention cassandra-env.sh
. Anyway, let me answer the main part of the question.
在JDK 8中,当未指定-Xmx
时,最大堆大小估计为
In JDK 8, when -Xmx
is not specified, the maximum heap size is estimated as
MaxHeapSize = min(1/4 RAM, max_heap_for_compressed_oops)
在您的情况下,服务器具有大量的RAM,因此默认堆大小受基于零的压缩oop支持的最大可能大小(即32 GB)限制.
In your case the server has plently of RAM, so the default heap size is limited by the maximum possible size supported by zero-based compressed oops, that is, 32 GB.
The heap obviously cannot start at zero address (null page is reserved by the OS), and the default heap alignment is 2 MB, so we must subtract at least 2 MB.
然后,JDK倾向于在HeapBaseMinAddress
处分配堆,该堆位于
Then, JDK prefers to allocate the heap at HeapBaseMinAddress
, which is equal to 2 GB on Linux. This provides some space to grow the native heap of the process. For this reason JVM reduces the default maximum heap size by HeapBaseMinAddress
.
这就是为什么最终计算出的堆大小等于
That's why the final computed heap size is equal to
32 GB - 2 MB - 2 GB = 32210157568
如果放弃对从零开始的压缩oop的要求,则可以设置-XX:HeapBaseMinAddress=0
.在这种情况下,计算出的堆大小将为
If you give up the requirement for the zero-based compressed oops, you may set -XX:HeapBaseMinAddress=0
. In this case the computed heap size would be
32 GB - 2MB = 32766 MB
这篇关于Cassandra中的堆内存默认分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!