




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JAVA JVM GC LOG分析和调优【转】2010-09-09 22:55:48|分类: java 性能 |举报 |字号订阅 在 大型的java运用中,要进行程序调优,指定一个合适的垃圾回收机制是必不可少的,那如何可确定某gc是否使得程序最优化呢?我们可以查看jvm打印出 的gc日志来分析,并做出进一步优化,而目前并没有一篇文章明确的指明java中各种gc算法打印出日志的格式,以及如何阅读。所以接下来本文将试着边介 绍各种垃圾回收机制边解释该回收机制下log的格式。1,垃圾收集算法1.1 引用计数法(Reference Counting Collector)系统记 录对象被应用的次数,当应用次数为0时,就可以将该对象所占内存回收。该算法可以不用暂停运用,但缺点是无法解决重复运用的问题。所以java并没有提供 此类垃圾回收器。1.2tracing算法(Tracing Collector)tracing算法的垃圾收集器从根集开始扫描,识别出哪些对象可达,哪 些对象不可达,并用某种方式标记可达对象。1.2.1复制 ( Copying )算法复 制算法将堆等分成2个区域,一个区域含有现在的数据对象(ToSpace),而另一个区域包含废 弃的数据(FromSpace)。复制算法将存活的对象从FromSpace复制到ToSpace,然后切换Fromspace和ToSpace的指针, 以前的FromSpace变为现在的ToSpace区域。 1.2.2标记整理( Mark-Compact )算法1.2.3 标记-清除(Mark-Sweep)Using the -XX flags for our collectors for jdk6, UseSerialGC is Serial + Serial Old UseParNewGC is ParNew + Serial Old UseConcMarkSweepGC is ParNew + CMS + Serial Old. CMS is used most of the time to collect the tenured generation. Serial Old is used when a concurrent mode failure occurs. UseParallelGC is Parallel Scavenge + Serial Old UseParallelOldGC is Parallel Scavenge + Parallel OldSerailGC1,Serial Young GC0.246: GC 0.246: DefNew: 1403K-105K(1984K), 0.0109275 secs 1403K-1277K(6080K), 0.0110143 secs2, Serial Olg Gc1.133: GC 1.133: DefNew: 960K-64K(960K), 0.0012208 secs1.135: Tenured: 7334K-7142K(7424K), 0.0213756 secs 7884K-7142K(8384K), Perm : 364K-364K(12288K), 0.0226997 secs Times: user=0.01 sys=0.00, real=0.02 secsParrallel GCserailGC的适应muti Core的加强版,就是在minorGC时候采用并行的进行收集,而fullGC并没有改变Parralllel Compacting GC在parrallelGC的基础上将fullgc也变为并发的了With the parallel compacting collector, the old and permanent generations are collected in a stop-theworld,mostly parallel fashion with sliding compaction. The collector utilizes three phases. First, each generation is logically divided into fixed-sized regions. In the marking phase, the initial set of live objects directly reachable from the application code is divided among garbage collection threads, and then all live objects are marked in parallel. As an object is identified as live, the data for the region it is in is updated with information about the size and location of the object.备注 待翻译Concurrent Mark-Sweep (CMS) Collector 有一种需求是应用的相应时间比应用的吞吐重要,为了满足这种需求,jvm提供了该场景下的垃圾收集器CMS,使用该垃圾收集器的时候minorGC和 ParralelGC当中采用的一样,只是在老生代更换了不同的算法。CMS将老生代的回收分为4个阶段 其中只有2个阶段是要stop-the-world的,而其余阶段是不需要的,因此降低了系统暂停时间,缺点是在其余的2个阶段会更应用抢jvm资源。从上图可以看出,CMS的运 行过程。A collection cycle for the CMS collector starts with a short pause, called the initial mark, thatidentifies the initial set of live objects directly reachable from the application code. Then,during the concurrent marking phase, the collector marks all live objects that are transitivelyreachable from this set. Because the application is running and updating reference fields while the marking phase is taking place, not all live objects are guaranteed to be marked at the end of the concurrent marking phase. To handle this, the application stops again for a second pause, called remark, which finalizes marking by revisiting any objects that were modified during the concurrent marking phase. Because the remark pause is more substantial than the initial mark, multiple threads are run in parallel to increase its efficiency.备注 待翻译Concurrent Mark-Sweep GC log format:Full GC 被调用的出现情况promotion failed(mark-sweep-compact stop-the-world)ParNew (promotion failed): 当老生代空闲空间存在碎片,导致没有足够大的连续空间开存放新生代对象的升级时,机会触发promotion failed。此时调用一个Mark-Compact 垃圾收集器是很有必要的。(默认采用 Serial Old GC)106.641: GC 106.641: ParNew (promotion failed): 14784K-14784K(14784K), 0.0370328 secs106.678:CMS106.715: CMS-concurrent-mark: 0.065/0.103 secs Times: user=0.17 sys=0.00, real=0.11 secs(concurrent mode failure): 41568K-27787K(49152K), 0.2128504 secs 52402K-27787K(63936K), CMS Perm : 2086K-2086K(12288K), 0.2499776 secs Times: user=0.28 sys=0.00, real=0.25 secsfull promotion guarantee failure(concurrent mode failure):当 垃圾回收算法预测在下一次Conc-Mark-Sweep算法调用之前,老生代的空余空间将会被系统占用光。为了解决这一问题,垃 圾回收算法进入conccurent mode failure状态,调用一个 stop-the-world(serail Old GC)来清理系统Heap。eg:为了触发这种情况 我们先分配64m内存给jvm,然后新生代和老年代的占用比例为7,即老年代用了7*8=58 触 发concurrent mode failure的情况:public class FullPromotionGuaranteeFailurepublic static void main(String args)List bytesList = new ArrayList();for (int i = 0; i test.log3. content=sed-n$ptest.log4. percent=sed-n$ptest.log|awkprint$4|awk-F%print$15. echo$percent6.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 学年第一学期幼儿教学工作总结模版
- 创先争优个人学习心得体会模版
- 新生儿单纯疱疹病毒感染的临床护理
- 社保委托代表协议
- 重力教学设计
- 上学期八年级语文教学工作总结模版
- 某精密模具有限公司品质管理系统
- 猫咪输液护理常规
- 部编本大小多少教学设计
- 7S管理培训体系精要
- 2024年高中英语衡水体书法练字字帖
- 融资融券实务
- 人教版二年级下册口算题天天练1000道可打印带答案
- 2022北京东城六年级毕业考英语试题含答案
- 部编版三年级语文下册口语交际:劝告 课件
- 《药物分析与检验技术》课件-异烟肼中游离肼的检查方法
- 手术室的健康教育
- 海水的淡化技术及应用
- 食堂餐饮服务方案
- 中职学校设计说明
- 医保政策下物价培训课件
评论
0/150
提交评论