设为首页 加入收藏

TOP

Java垃圾收集器之Serial Old收集器(一)
2015-02-02 14:17:21 来源: 作者: 【 】 浏览:19
Tags:Java 垃圾 收集器 Serial Old

Serial Old收集器是JAVA虚拟机中垃圾收集器的一种,它是Serial收集器的老年代版本,它同样是一个单线程收集器,使用“标记-整理”算法。这个收集器的主要也是在目前的JAVA的Client模式下的虚拟机使用。如果在Server模式下,它主要还有两大用途:一个是在JDK 1.5及之前的版本中与Parallel Scavenge收集器搭配使用,另外一个就是作为CMS收集器的后备预案。如果CMS收集器出现Concurrent Mode Failure,则Serial Old收集器将作为后备收集器。


1、简单示例


源代码


package com.gc;


?


import java.util.ArrayList;


import java.util.List;


?


/**


?* 简单的JAVA虚拟机内存回收,serial old收集器的使用


?* 参数:-Xms30m -Xmx100m-Xmn10m -XX:+UseSerialGC -XX:+PrintGCDetails


?* @author 范芳铭


?*/


public class EasySerialOld {


? ? ? public byte[] placeHolder =new byte[64 * 1024]; //占位符


? ? ? public static voidmain(String[] args) throws Exception{


? ? ? ? ? ? ? outOfMemoryByExpansionSize();


? ? ? }


? ? ?


? ? ?


? ? ? private static voidoutOfMemoryByExpansionSize() throws Exception{


? ? ? ? ? ? ? Listlist = new ArrayList();


? ? ? ? ? ? ? while(true){


? ? ? ? ? ? ? ? ? ? EasySerialOldserial = new EasySerialOld();


? ? ? ? ? ? ? ? ? ? list.add(serial);


? ? ? ? ? ? ? ? ? ? Thread.sleep(10);//停顿10毫秒


? ? ? ? ? ? ? }


? ? ? }


}


参数


-Xms30m? JVM最小30M


-Xmx100m? JVM最大100M


-Xmn10m? 新生代固定10M


-XX:+UseSerialGC? 对应serial + serial old 收集器


-XX:+PrintGCDetails 打印详细GC


运行结果


[GC [DefNew: 8137K->1023K(9216K),0.0070798 secs] 8137K->8019K(29696K), 0.0071114 secs] [Times: user=0.00sys=0.00, real=0.01 secs]


[GC [DefNew: 9175K->963K(9216K),0.0056184 secs] 16170K->16151K(29696K), 0.0056422 secs] [Times: user=0.00sys=0.00, real=0.00 secs]


[GC [DefNew: 9149K->964K(9216K),0.0050408 secs][Tenured: 23320K->23388K(23424K), 0.0030744 secs]24337K->24284K(32640K), [Perm : 2086K->2086K(12288K)], 0.0082092 secs][Times: user=0.00 sys=0.00, real=0.01 secs]


[GC [DefNew: 8166K->964K(9216K),0.0052883 secs] 31555K->31522K(48200K), 0.0053220 secs] [Times: user=0.00sys=0.00, real=0.01 secs]


[GC [DefNew: 9118K->962K(9216K),0.0050018 secs] 39676K->39654K(48200K), 0.0050367 secs] [Times: user=0.00sys=0.02, real=0.00 secs]


[GC [DefNew: 9108K->966K(9216K),0.0049332 secs][Tenured: 46824K->46893K(46920K), 0.0033687 secs]47800K->47790K(56136K), [Perm : 2086K->2086K(12288K)], 0.0084489 secs][Times: user=0.02 sys=0.00, real=0.01 secs]


[GC [DefNew: 8141K->963K(9216K),0.0056947 secs] 55034K->55026K(87372K), 0.0057206 secs] [Times: user=0.00sys=0.00, real=0.01 secs]


[GC [DefNew: 9099K->962K(9216K),0.0046619 secs] 63162K->63158K(87372K), 0.0046951 secs] [Times: user=0.00sys=0.00, real=0.00 secs]


[GC [DefNew: 9102K->968K(9216K),0.0048499 secs] 71298K->71296K(87372K), 0.0048757 secs] [Times: user=0.00sys=0.00, real=0.00 secs]


[GC [DefNew: 9104K->962K(9216K),0.0053368 secs][Tenured: 78465K->78531K(78540K), 0.0035892 secs]79431K->79427K(87756K), [Perm : 2086K->2086K(12288K)], 0.0090187 secs][Times: user=0.00 sys=0.00, real=0.01 secs]


[GC [DefNew: 8134K->962K(9216K),0.0061709 secs] 86665K->86663K(101376K), 0.0061952 secs] [Times: user=0.00sys=0.00, real=0.01 secs]


[GC [DefNew: 9096K->9096K(9216K),0.0000242 secs][Tenured: 85701K->92157K(92160K), 0.0230609 secs]94797K->94783K(101376K), [Perm : 2086K->2084K(12288K)], 0.0231402 secs][Times: user=0.03 sys=0.00, real=0.02 secs]


[Full GC [Tenured:92157K->92157K(92160K), 0.0044209 secs] 101264K->101260K(101376K), [Perm: 2084K->2084K(12288K)], 0.0044763 secs] [Times: user=0.00 sys=0.00,real=0.00 secs]


[Full GC [Tenured:92157K->92151K(92160K), 0.0072855 secs] 101260K->101254K(101376K), [Perm: 2084K->2084K(12288K)], 0.0073138 secs] [Times: user=0.00 sys=

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Java垃圾收集器之Parallel Old收.. 下一篇Java垃圾收集器之概说

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: