码迷,mamicode.com
首页 > 系统相关 > 详细

JVM学习之Eclipse输出GC日志

时间:2016-01-12 21:31:03      阅读:372      评论:0      收藏:0      [点我收藏+]

标签:

     Java应用启动时,可以通过设置verbose参数来输出JVM的gc情况,命令如下:-verbose:gc或者-XX:+PrintGC
在Eclipse中可以通过Run As|Run Configurations|Arguments|VM Arguments进行设置。
使用该命令后输出如下:

 1 [GC 3375K->1317K(15872K), 0.0047372 secs]
 2 [GC 4973K->3427K(15872K), 0.0084376 secs]
 3 [GC 11340K->8175K(15872K), 0.0027110 secs]
 4 [Full GC 8175K->5127K(15872K), 0.0148359 secs]
 5 [GC 12249K->12249K(23060K), 0.0035303 secs]
 6 [Full GC 12249K->7501K(23060K), 0.0197696 secs]
 7 [GC 18184K->18184K(36944K), 0.0057985 secs]
 8 [Full GC 18184K->11062K(36944K), 0.0245650 secs]
 9 [GC 27086K->27086K(41744K), 0.0073461 secs]
10 [Full GC 27086K->16403K(41744K), 0.0343230 secs]

    箭头(->)前后的数据3375K和1317K分别表示垃圾收集GC前后所有存活对象使用的内存容量,说明有3375K–1317K = 2258K大小的对象被回收,括号内的数据 123584K为堆内存的总容量,收集所需的实际为 0.0120528秒。需要注意的是:GC会暂用CPU时间片,会造成程序短暂的停顿,控制台输出GC信息还可以使用如下命令:
    在JVM的启动参数中加入:

  (1)-XX:+PrintGC,输出GC的简要信息

  (2)-XX:+PrintGCDetails,输出GC的详细信息:

 

1 [GC[DefNew: 3375K->379K(4928K), 0.0041917 secs] 3375K->1317K(15872K), 0.0042904 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2 [GC[DefNew: 4035K->0K(4928K), 0.0088287 secs] 4973K->3427K(15872K), 0.0088957 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
3 [GC[DefNew: 3165K->0K(4928K), 0.0026064 secs][Tenured: 8175K->5127K(10944K), 0.0146668 secs] 11340K->5127K(15872K), [Perm : 160K->160K(12288K)], 0.0173788 secs] [Times: user=0.02 sys=0.00, real=0.02 secs] 
4 [GC[DefNew: 0K->0K(4992K), 0.0040182 secs][Tenured: 12249K->7501K(18068K), 0.0179673 secs] 12249K->7501K(23060K), [Perm : 160K->160K(12288K)], 0.0221141 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 
5 [GC[DefNew: 0K->0K(8192K), 0.0050559 secs][Tenured: 18184K->11062K(28752K), 0.0257729 secs] 18184K->11062K(36944K), [Perm : 160K->160K(12288K)], 0.0309780 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 
6 [GC[DefNew: 0K->0K(12992K), 0.0076682 secs][Tenured: 27086K->16403K(28752K), 0.0363194 secs] 27086K->16403K(41744K), [Perm : 160K->160K(12288K)], 0.0440790 secs] [Times: user=0.05 sys=0.00, real=0.04 secs]

 

(3)-XX:+PrintGCTimeStamps,输出GC的时间信息如下:

(4)-XX:+PrintGCApplicationStoppedTime,GC造成的应用暂停的时间

 

1 Total time for which application threads were stopped: 0.0040944 seconds
2 Total time for which application threads were stopped: 0.0089377 seconds
3 Total time for which application threads were stopped: 0.0176941 seconds
4 Total time for which application threads were stopped: 0.0218115 seconds
5 Total time for which application threads were stopped: 0.0293873 seconds
6 Total time for which application threads were stopped: 0.0420044 seconds
7 Total time for which application threads were stopped: 0.0607124 seconds

 

JVM学习之Eclipse输出GC日志

标签:

原文地址:http://www.cnblogs.com/sunfie/p/5125511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!