测试jdk8.垃圾回收机制

/**
 * 测试垃圾回收机制
 * @author zk_zyzs@aliyun.com
 *
 */
public class Test {
	private Object instance;

	public static void main(String[] args) {
		//创建引用
		Test test =new Test();
		Test test2=new Test();
		//设置引用
		test.instance=test2;
		test2.instance = test;
		//释放对象
		test=null;
		test2=null;
		
		System.gc();
	}
	
}

[GC (System.gc()) [PSYoungGen: 1996K->632K(38400K)] 1996K->640K(125952K), 0.0019813 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[Full GC (System.gc()) [PSYoungGen: 632K->0K(38400K)] [ParOldGen: 8K->521K(87552K)] 640K->521K(125952K), [Metaspace: 2642K->2642K(1056768K)], 0.0096864 secs] [Times: user=0.05 sys=0.00, real=0.01 secs] 
Heap
 PSYoungGen      total 38400K, used 333K [0x00000000d5d00000, 0x00000000d8780000, 0x0000000100000000)
  eden space 33280K, 1% used [0x00000000d5d00000,0x00000000d5d534a8,0x00000000d7d80000)
  from space 5120K, 0% used [0x00000000d7d80000,0x00000000d7d80000,0x00000000d8280000)
  to   space 5120K, 0% used [0x00000000d8280000,0x00000000d8280000,0x00000000d8780000)
 ParOldGen       total 87552K, used 521K [0x0000000081600000, 0x0000000086b80000, 0x00000000d5d00000)
  object space 87552K, 0% used [0x0000000081600000,0x00000000816827b8,0x0000000086b80000)
 Metaspace       used 2648K, capacity 4486K, committed 4864K, reserved 1056768K
  class space    used 285K, capacity 386K, committed 512K, reserved 1048576K

************执行虚拟机需要配置如下参数:-verbose:gc -XX:+PrintGCDetails ***************

从执行结果可以看出垃圾回收机制用的叫  Parallel

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值