Java8 jvm参数简介

来源:互联网 发布:深入理解java虚拟机pdf 编辑:程序博客网 时间:2024/06/05 15:55

1、用jmap命令输出
用jmap输出

2、解析

MaxHeapFreeRatio: GC后如果发现空闲堆内存占到整个预估堆内存的N%(百分比),则收缩堆内存的预估最大值, 预估堆内存是堆大小动态调控的重要选项之一. 堆内存预估最大值一定小于或等于固定最大值(-Xmx指定的数值). 前者会根据使用情况动态调大或缩小, 以提高GC回收的效率MinHeapFreeRatio: GC后如果发现空闲堆内存占到整个预估堆内存的N%(百分比), 则放大堆内存的预估最大值MaxHeapSize: 即-Xmx, 堆内存大小的上限InitialHeapSize: 即-Xms, 堆内存大小的初始值NewSize: 新生代预估堆内存占用的默认值MaxNewSize: 新生代占整个堆内存的最大值OldSize: 老年代的默认大小, default size of the tenured generationNewRatio: 老年代对比新生代的空间大小, 比如2代表老年代空间是新生代的两倍大小. The ratio of old generation to young generation.SurvivorRatio: Eden/Survivor的值. 这个值的说明, 很多网上转载的都是错的. 8表示Survivor:Eden=1:8, 因为survivor区有2个, 所以Eden的占比为8/10. Ratio of eden/survivor space size. -XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6, each survivor space will be one eighth of the young generation. MetaspaceSize: 分配给类元数据空间的初始大小(Oracle逻辑存储上的初始高水位,the initial high-water-mark ). 此值为估计值. MetaspaceSize设置得过大会延长垃圾回收时间. 垃圾回收过后, 引起下一次垃圾回收的类元数据空间的大小可能会变大MaxMetaspaceSize: 是分配给类元数据空间的最大值, 超过此值就会触发Full GC. 此值仅受限于系统内存的大小, JVM会动态地改变此值CompressedClassSpaceSize: 类指针压缩空间大小, 默认为1GG1HeapRegionSize: G1区块的大小, 取值为1M至32M. 其取值是要根据最小Heap大小划分出2048个区块. With G1 the Java heap is subdivided into uniformly sized regions. This sets the size of the individual sub-divisions. The default value of this parameter is determined ergonomically based upon heap size. The minimum value is 1Mb and the maximum value is 32Mb. Sets the size of a G1 region. The value will be a power of two and can range from 1MB to 32MB. The goal is to have around 2048 regions based on the minimum Java heap size.指针压缩1. 64位平台上默认打开  1)使用-XX:+UseCompressedOops压缩对象指针    "oops"指的是普通对象指针("ordinary" object pointers)。    Java堆中对象指针会被压缩成32位。    使用堆基地址(如果堆在低26G内存中的话,基地址为02)使用-XX:+UseCompressedClassPointers选项来压缩类指针    对象中指向类元数据的指针会被压缩成32位    类指针压缩空间会有一个基地址2. 元空间和类指针压缩空间的区别  1)类指针压缩空间只包含类的元数据,比如InstanceKlass, ArrayKlass    仅当打开了UseCompressedClassPointers选项才生效    为了提高性能,Java中的虚方法表也存放到这里    这里到底存放哪些元数据的类型,目前仍在减少  2)元空间包含类的其它比较大的元数据,比如方法,字节码,常量池等。

3、用jstat命令输出
这里写图片描述

4、解析

S0: Survivor 0区的空间使用率 Survivor space 0 utilization as a percentage of the space's current capacity.S1: Survivor 1区的空间使用率 Survivor space 1 utilization as a percentage of the space's current capacity.E: Eden区的空间使用率 Eden space utilization as a percentage of the space's current capacity.O: 老年代的空间使用率 Old space utilization as a percentage of the space's current capacity.M: 元数据的空间使用率 Metaspace utilization as a percentage of the space's current capacity.CCS: 类指针压缩空间使用率 Compressed class space utilization as a percentage.YGC: 新生代GC次数 Number of young generation GC events.YGCT: 新生代GC总时长 Young generation garbage collection time.FGC: Full GC次数 Number of full GC events.FGCT: Full GC总时长 Full garbage collection time.GCT: 总共的GC时长 Total garbage collection time.

记录GC日志
加入参数

-verbose:gc -Xloggc:$CATALINA_BASE/logs/gc.log XX:+PrintGCTimeStamps -XX:+PrintGCDetails
export JAVA_HOME=/opt/java/jdk1.8.0_101export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.0.36-redisexport CATALINA_BASE=/home/tomcat/tomcat8_jdk8export JAVA_OPTS="-server -Xms1280m -Xmx1280m -XX:MaxNewSize=896m -Djava.awt.headless=true -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc.log -XX:+PrintGCTimeStamps -XX:+PrintGCDetails"cd $CATALINA_HOME/bin./catalina.sh start

若jvm进程不明原因退出, 可以查看syslog, 位置是 /var/log/messages。

原创粉丝点击