Does G1 GC have a max size of region or max amount of region?(G1 GC 是否有最大区域大小或最大区域数量?)
问题描述
我在学习 G1 GC 时,发现了这篇文章:http:///www.oracle.com/technetwork/articles/java/g1gc-1984535.html.在那篇文章中,有一段话是这样说的:
when i studied G1 GC, I found this article: http://www.oracle.com/technetwork/articles/java/g1gc-1984535.html. In that article, there is something says as follow:
G1 GC 是一个区域化和分代的垃圾收集器,这意味着 Java 对象堆(heap)被划分为多个大小相等的区域.启动时,Java 虚拟机 (JVM) 设置区域大小.区域大小可以从 1 MB 到 32 MB 不等,具体取决于堆大小.目标是不超过 2048 个区域.
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 heap memory的最大大小是2048 * 32M,如果超过了会怎样?
Does that mean the max size of java heap memory that G1 GC can deal with is 2048 * 32M, and if the size exceeds it, what will happen?
推荐答案
来自 HotSpot JVM 源代码:
// 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) 是硬限制;TARGET_REGION_NUMBER
只是一个提示,如果未在 JVM 选项中指定,则用于计算默认区域大小.实际数量可能会超过此值.MIN_REGION_SIZE
(1MB) andMAX_REGION_SIZE
(32MB) are hard limits;TARGET_REGION_NUMBER
is just a hint that is used to calculate default region size if it is not specified among JVM options. The actual number may exceed this value.
这篇关于G1 GC 是否有最大区域大小或最大区域数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:G1 GC 是否有最大区域大小或最大区域数量?


基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 降序排序:Java Map 2022-01-01