`
he_wen
  • 浏览: 234139 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

JVM 参数设置

    博客分类:
  • JVM
阅读更多

 

JVM 参数设置

参考文献:http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html

 

某个大流量网站中JVM参数设置如下:

 

 

 

-Xms10000M -Xmx10000M -Xmn5000M

-Xss128k

-XX:PermSize=256m

-XX:MaxPermSize=512m

-XX:+UseParNewGC

-XX:ParallelGCThreads=8                       默认开启回收线程数(并行GC线程数+3)/4

-XX:SurvivorRatio=6

-XX:TargetSurvivorRatio=90

-XX:MaxTenuringThreshold=30                       控制对象在新生代存活的最大次数

-XX:+UseConcMarkSweepGC

-XX:+UseCMSCompactAtFullCollection             下面两个参数,由于CMS会产生垃圾浮点,所以每执行5次full GC

-XX:CMSFullGCsBeforeCompaction=5                内存就进行整理

-XX:CMSInitiatingOccupancyFraction=55        旧生代使用55%的比例触发full GC

-XX:SoftRefLRUPolicyMSPerMB=0                 

-XX:CMSIncrementalSafetyFactor=20            ??????????????

-XX:+CMSIncrementalMode                          ?????????????

-XX:+UseCMSInitiatingOccupancyOnly         禁止hotspot自行触发CMS GC

-XX:+PrintGCDetails -XX:+PrintGCTimeStamp

考虑的是持久代的GC也可以设置:-XX:+CMSPermGenSweepingEnabled,-XX:+CMSClassUnloadingEnabled

 

 

额外参数需要考虑的:

-XX:+DisableExplicitGC禁止System.gc()

 

-XX:SoftRefLRUPolicyMSPerMB

softly reachable objects will remain alive for some amount of time after the last time they were referenced. The default value is one second of lifetime per free megabyte in the heap,我觉得没必要等1秒; 

 

如果在CMS算法中配置了: -XX:+UseAdaptiveSizePolicy 表示堆中各个区的比例由JVM自己分配即动态变化

-XX:+DisableExplicitGC禁止System.gc()

 

CMS算法

 

优点:

  • 在Old进行回收时,对应用的暂停时间非常短,适合对latency要求高的应用

缺点:

  • 内存碎片和浮动垃圾
  • Old区内存分配效率低
  • 回收的整个耗时比较长
  • 和应用争取CPU

二、内存回收触发机制

 

1、YGC   eden空间不足

2、CMS GC

  • Old区域使用达到一定的比例,默认是92%
  • 配置了CMSClassunloadingEnabled,且Perm 区域使用达到一定比例,默认92%
  • hotspot自己根据估计决定是否要触发
  • 在配置ExplicitGCInvokesConcurrent的情况下调用了System.gc

Full GC如果出现了Promotion failed 或Concurrent Mode Failure 时,GC采用 serial MSC

promotion failed,(Xmx-Xmn)*(100-CMSInitiatingOccupancyFraction)/100>=Xmn

 

三、对于CMS算法中增量模式的解释

 

-XX:+CMSIncrementalMode

 

请看原文的意思:

The concurrent collector can be used in a mode in which the concurrent phases are done 
incrementally. Recall that during a concurrent phase the garbage collector thread is using a processor. 
The incremental mode is meant to lessen the impact of long concurrent phases by periodically stopping
 the concurrent phase to yield back the processor to the application. This mode 
(referred to here as “i-cms”) divides the work done by concurrently by the collector into small chunks
 of time which are scheduled between young generation collections. This feature is useful when 
applications that need the low pause times provided by the concurrent collector are run on machines 
with small numbers of processors (e.g., 1 or 2).

The concurrent collection cycle typically includes the following steps:

    stop all application threads; do the initial mark; resume all application threads

    do the concurrent mark (uses one procesor for the concurrent work)

    do the concurrent pre-clean (uses one processor for the concurrent work)

    stop all application threads; do the remark; resume all application threads

    do the concurrent sweep (uses one processor for the concurrent work)

    do the concurrent reset (uses one processor for the concurrent work)

Normally, the concurrent collector uses one processor for the concurrent work for the entire 
concurrent mark phase, without (voluntarily) relinquishing it. Similarly, one processor is used for the
 entire concurrent sweep phase, again without relinquishing it. This processor utilization can be too
 much of a disruption for applications with pause time constraints, particularly when run on systems 
with just one or two processors. i-cms solves this problem by breaking up the concurrent phases into
 short bursts of activity, which are scheduled to occur mid-way between minor pauses.

I-cms uses a "duty cycle" to control the amount of work the concurrent collector is allowed to do 
before voluntarily giving up the processor. The duty cycle is the percentage of time between young 
generation collections that the concurrent collector is allowed to run. I-cms can automatically compute
 the duty cycle based on the behavior of the application (the recommended method), or the duty cycle
 can be set to a fixed value on the command line.
 

 

The following command-line options control i-cms (see below for recommendations for an initial set of 
options):

-XX:+CMSIncrementalMode default: disabled

This flag enables the incremental mode. Note that the concurrent collector must be enabled (with 
-XX:+UseConcMarkSweepGC) for this option to work.

-XX:+CMSIncrementalPacing default: disabled

This flag enables automatic adjustment of the incremental mode duty cycle based on statistics 
collected while the JVM is running.

-XX:CMSIncrementalDutyCycle=<N> default: 50

This is the percentage (0-100) of time between minor collections that the concurrent collector is
 allowed to run. If CMSIncrementalPacing is enabled, then this is just the initial value.

-XX:CMSIncrementalDutyCycleMin=<N> default: 10

This is the percentage (0-100) which is the lower bound on the duty cycle when CMSIncrementalPacing 
is enabled.

-XX:CMSIncrementalSafetyFactor=<N> default: 10

This is the percentage (0-100) used to add conservatism when computing the duty cycle.

-XX:CMSIncrementalOffset=<N> default: 0

This is the percentage (0-100) by which the incremental mode duty cycle is shifted to the right within 
the period between minor collections.

-XX:CMSExpAvgFactor=<N> default: 25

This is the percentage (0-100) used to weight the current sample when computing exponential 
averages for the concurrent collection statistics.

5.4.9.2 Recommended Options for i-cms

When trying i-cms, we recommend the following as an initial set of command line options:

-XX:+UseConcMarkSweepGC \

-XX:+CMSIncrementalMode \

-XX:+CMSIncrementalPacing \

-XX:CMSIncrementalDutyCycleMin=0 \

-XX:+CMSIncrementalDutyCycle=10 \

-XX:+PrintGCDetails \

-XX:+PrintGCTimeStamps \

-XX:-TraceClassUnloading

 所以要慎重的使用该参数,不要使用JVM自己收集JVM信息去触发GC,自己使用过该参数,深有体会,full gc不可控。

0
0
分享到:
评论

相关推荐

    jvm参数设置_JVM参数设置_

    JVM参数设置,提供java虚拟机运行时的参数设置

    JVM参数设置详细说明

    JVM参数设置详细说明、JVM 参数设置详细说明 1: heap size a: -Xmx 指定jvm的最大heap大小,如:-Xmx=2g b: -Xms 指定jvm的最小heap大小,如:-Xms=2g,高并发应用,建议和-Xmx一样,防止因为内存收缩/突然增大带来...

    jvm参数设置

    linux 下jvm基本参数设置 查看linux jvm的设置基本命令

    JVM参数设置

    通过设置JVM的参数设置,可以提高系统的稳定性与效率

    JVM 参数设置详解

    This document is a compilation of all the JVM options for various versions of the JVM on primarily SPARC/Solaris Platform. The descriptions for each option are taken mostly verbatim from the reference...

    myeclipsejava虚拟机jvm参数设置

    在使用MyEclipse的过程中经常出现内存不足的提示: MyEclipse has detected that less than 5% of the 31MB of Eden Space (Heap memory) space remains. It is strongly recommended that you exit and restart ...

    eclipse中对jvm进行设置

    你对Eclipse中JVM内存设置方法是否熟悉,这里通过几个问题向大家解释一下,安装Java开发软件时,默认安装包含两个文件夹,一个JDK(Java开发工具箱),一个JRE(Java运行环境,内含JVM),其中JDK内另含一个JRE。

    was使用及参数设置

    was使用及参数设置 was使用及参数设置 was使用及参数设置

    如何配置jvm参数,调优

    如何配置jvm参数,并且调优,适合各路开发者,

    JVM入门实战/arthas实战/垃圾回收算法/垃圾回收器/jvm内存模型分析

    本系列课程从JVM基础到高级实战,老师手把手教你如何进行JVM...1.3JVM参数设置思路1.4JVM调优常用指令说明 第七节:JVM项目实战 1.1案例背景 1.2排查步骤 1.3.arthas 1.3.1.arthas简介 1.3.2.arthas实战 1.3总结

    设置Eclipse的JVM参数

    设置Eclipse的JVM参数

    java学习之JVM调优相关说明

    将机器的JVM参数设置到最优 一般的Java都不需要进行JVM优化 减少代码层面造成的GC问题(STW) 减少使用全局变量、大对象以及减少创建对象的数量 通过代码解决GC情况比优化JVM参数更好 架构和代码调优等级优先于JVM...

    tomcat6.0 修改启动内存设置 java jvm参数配置

    在/usr/local/apache-tomcat-5.5.23/bin目录下的catalina.sh 添加:JAVA_OPTS='-Xms512m -Xmx1024m' 要加“m”说明是MB,否则就是KB了,在启动tomcat时会报内存不足。 -Xms:初始值 ...重起tomcat服务,设置生效

    关键业务系统JVM参数推荐

    常用的JVM参数,适合于线上关键业务系统,通用参数设置经验

    jvm 参数调优实践

    jvm 参数调优实践,有代码可供参考,详细调优比较!

    JVM性学习笔记-基本原理,内存模型,JVM参数

    JVM性学习笔记-基本原理,内存模型,JVM参数设置,类加载器原理,JDK自带工具

    JVM 参数详解-基于jdk1.7

    (中英文)JVM 参数详解,用心整理成Excel文档。包含所有近100条JVM参数的详细说明及设置方法,中英文对照,极方便阅读。转载请标明我这的源地址:http://download.csdn.net/download/xiucaiyao/10257573

    JVM常用参数设置

    NULL 博文链接:https://ajita.iteye.com/blog/1985134

    jvm参数与系统性能的优化

    可通过设置jvm参数,提高系统性能。内含一些系统原理。

    常用JVM配置参数.ppt

    常用JVM配置参数.ppt

Global site tag (gtag.js) - Google Analytics