G1 GC是否具有最大区域大小或最大区域数量?

问题描述

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选项中未指定默认区域大小,则该提示仅用于计算默认区域大小。实际数字可能超过此值。

解决方法

在研究G1
GC时,我发现了这篇文章:http
:
//www.oracle.com/technetwork/articles/java/g1gc-1984535.html。在该文章中,内容如下:

G1
GC是一个区域化的,按代划分的垃圾收集器,这意味着Java对象堆(堆)被划分为多个大小相等的区域。启动时,Java虚拟机(JVM)设置区域大小。区域大小可以从1
MB到32 MB不等,具体取决于堆大小。目标是不超过2048个区域。

这是否意味着G1 GC可以处理的Java堆内存的最大大小为2048 * 32M,如果超过该大小,将会发生什么?

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...