您的位置:首页 > 编程语言 > Java开发

Java8 jvm参数简介

2017-07-10 14:19 176 查看
一、用
jmap
命令输出




二、解析

MaxHeapFreeRatio
:
GC
后如果发现空闲堆内存占到整个预估堆内存的N%(百分比),则收缩堆内存的预估最大值, 预估堆内存是堆大小动态调控的重要选项之一. 堆内存预估最大值一定小于或等于固定最大值(-Xmx指定的数值). 前者会根据使用情况动态调大或缩小, 以提高
GC
回收的效率

MinHeapFreeRatio
:
GC
后如果发现空闲堆内存占到整个预估堆内存的N%(百分比), 则放大堆内存的预估最大值

MaxHeapSize:
-Xmx
, 堆内存大小的上限

InitialHeapSize:
-Xms
, 堆内存大小的初始值

NewSize:
新生代预估堆内存占用的默认值

MaxNewSize:
新生代占整个堆内存的最大值

OldSize:
老年代的默认大小,
default size of the tenured generation


NewRatio:
老年代对比新生代的空间大小, 比如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
: 类指针压缩空间大小, 默认为1G

G1HeapRegionSize
:
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、指针压缩1. 64位平台上默认打开

使用
-XX:+UseCompressedOops
压缩对象指针

"oops"
指的是普通对象指针(
"ordinary" object pointers
)。

Java
堆中对象指针会被压缩成32位。

使用堆基地址(如果堆在低26G内存中的话,基地址为0)

使用
-XX:+UseCompressedClassPointers
选项来压缩类指针

对象中指向类元数据的指针会被压缩成32位

类指针压缩空间会有一个基地址

2、元空间和类指针压缩空间的区别

类指针压缩空间只包含类的元数据,比如
InstanceKlass, ArrayKlass


仅当打开了
UseCompressedClassPointers
选项才生效

为了提高性能,
Java
中的虚方法表也存放到这里

这里到底存放哪些元数据的类型,目前仍在减少

元空间包含类的其它比较大的元数据,比如方法,字节码,常量池等。

三、用
jstat
命令输出




四、解析

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_101
export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.0.36-redis
export CATALINA_BASE=/home/tomcat/tomcat8_jdk8
export JAVA_OPTS="-server -Xms1280m -Xmx1280m -XX:MaxNewSize=896m -Djava.awt.hea
dless=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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jvm java