Why does G1 Old gen max memory in jmx equal to max heap size?

I start a tomcat instance enabled with jmx, I check G1 old gen memory stat, find max memory = max heap size.

  • The environment
  • # uname -a
    Linux bogon 2.6.32-642.15.1.el6.x86_64 #1 SMP Fri Feb 24 14:31:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    # cat /etc/redhat-release
    CentOS release 6.8 (Final)
    # java -version
    java version "1.8.0_65"
    Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
    Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
    
  • jvm option
  • # ps -ef|grep tomcat
    tomcat    3177     1  7 10:23 ?        00:00:06 /usr/java/jdk1.8.0_65//bin/java -Djava.util.logging.config.file=/apps/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms1696m -Xmx1696m -XX:+DisableExplicitGC -XX:MaxGCPauseMillis=200 -XX:+UseStringDeduplication -XX:MetaspaceSize=96m -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=45 -XX:MinMetaspaceFreeRatio=50 -XX:MaxMetaspaceFreeRatio=80 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintClassHistogram -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/tomcat/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=2M -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8415 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.rmi.port=8415 -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/apps/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/apps/tomcat/temp org.apache.catalina.startup.Bootstrap -Dprocessname=tomcat start
    
  • jmap result
  • # jmap -heap 3177
    Attaching to process ID 3177, please wait...
    Debugger attached successfully.
    Server compiler detected.
    JVM version is 25.65-b01
    
    using thread-local object allocation.
    Garbage-First (G1) GC with 1 thread(s)
    
    Heap Configuration:
       MinHeapFreeRatio         = 40
       MaxHeapFreeRatio         = 70
       MaxHeapSize              = 1778384896 (1696.0MB)
       NewSize                  = 1363144 (1.2999954223632812MB)
       MaxNewSize               = 1066401792 (1017.0MB)
       OldSize                  = 5452592 (5.1999969482421875MB)
       NewRatio                 = 2
       SurvivorRatio            = 8
       MetaspaceSize            = 100663296 (96.0MB)
       CompressedClassSpaceSize = 1073741824 (1024.0MB)
       MaxMetaspaceSize         = 17592186044415 MB
       G1HeapRegionSize         = 1048576 (1.0MB)
    
    Heap Usage:
    G1 Heap:
       regions  = 1696
       capacity = 1778384896 (1696.0MB)
       used     = 84934656 (81.0MB)
       free     = 1693450240 (1615.0MB)
       4.775943396226415% used
    G1 Young Generation:
    Eden Space:
       regions  = 81
       capacity = 93323264 (89.0MB)
       used     = 84934656 (81.0MB)
       free     = 8388608 (8.0MB)
       91.01123595505618% used
    Survivor Space:
       regions  = 0
       capacity = 0 (0.0MB)
       used     = 0 (0.0MB)
       free     = 0 (0.0MB)
       0.0% used
    G1 Old Generation:
       regions  = 0
       capacity = 1685061632 (1607.0MB)
       used     = 0 (0.0MB)
       free     = 1685061632 (1607.0MB)
       0.0% used
    
    12869 interned Strings occupying 1777832 bytes.
    
  • Question
  • The jmx item java.lang:type=MemoryPool,name=G1 Old Gen,Usage.max is 1778384896, it equals to the max heap size.

    If Old gen memory is not enough, all heap memory will be used for Old gen memory?

    链接地址: http://www.djcxy.com/p/82792.html

    上一篇: Java PermGen空间是整个虚拟机内存的一部分吗?

    下一篇: 为什么G1在jmx中的旧gen最大内存等于最大堆大小?