java – G1 GC是否具有区域的最大大小或区域的最大数量?
作者:互联网
当我研究G1 GC时,我发现这篇文章:http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html.在那篇文章中,有一些内容如下:
The G1 GC is a regionalized and generational garbage collector, which means that the Java object heap (heap) is divided into a number of equally sized regions. Upon startup, the Java Virtual Machine (JVM) sets the region size. The region sizes can vary from 1 MB to 32 MB depending on the heap size. The goal is to have no more than 2048 regions.
这是否意味着G1 GC可以处理的Java堆内存的最大大小是2048 * 32M,如果大小超过它,会发生什么?
解决方法:
// Minimum region size; we won't go lower than that.
// We might want to decrease this in the future, to deal with small
// heaps a bit more efficiently.
static const size_t MIN_REGION_SIZE = 1024 * 1024;
// Maximum region size; we don't go higher than that. There's a good
// reason for having an upper bound. We don't want regions to get too
// large, otherwise cleanup's effectiveness would decrease as there
// will be fewer opportunities to find totally empty regions after
// marking.
static const size_t MAX_REGION_SIZE = 32 * 1024 * 1024;
// The automatic region size calculation will try to have around this
// many regions in the heap (based on the min heap size).
static const size_t TARGET_REGION_NUMBER = 2048;
> MIN_REGION_SIZE(1MB)和MAX_REGION_SIZE(32MB)是硬限制;
>如果未在JVM选项中指定,则TARGET_REGION_NUMBER只是用于计算默认区域大小的提示.实际数字可能会超过此值.
标签:java,garbage-collection,jvm,g1gc 来源: https://codeday.me/bug/20190823/1701148.html