---
title: "JVM GC日志时间问题 "
author: "ikon"
date: "2012-07-18T14:22:33Z"
tags: []
categories: ["编程语言"]
slug: "jvm-gc"
draft: false
lastmod: "2012-07-18T14:22:33Z"
id: 1597510
url: "https://ikon.iteye.com/blog/1597510"
---

几乎所有的资料上说到打印JVM GC log的时候都会推荐一个参数： -XX:+PrintGCTimeStamps， 可该选项打印的是JVM以启动时间为基准的相对时间，对于troubleshooting来说非常困难。早在07年的时候就有人提出来并且早已fix，用法是使用 PrintGCDateStamps 代替PrintGCTimeStamps，打印出来的就是真实的日期了

 

示例如下：

 

haitao-yao@haitaoyao-laptop:/data/develop/yed-3.7$ java -jar -XX:+PrintGCDateStamps -XX:+PrintGCDetails -verbose:gc yed.jar 

2011-05-11T17:49:43.959+0800: \[GC \[PSYoungGen: 15360K-&gt;2464K(17856K)] 15360K-&gt;8417K(58688K), 0.0260480 secs] \[Times: user=0.05 sys=0.00, real=0.02 secs] 

2011-05-11T17:49:44.612+0800: \[GC \[PSYoungGen: 17824K-&gt;2484K(33216K)] 23777K-&gt;10471K(74048K), 0.0156130 secs] \[Times: user=0.03 sys=0.00, real=0.02 secs] 

2011-05-11T17:49:44.724+0800: \[GC \[PSYoungGen: 33204K-&gt;2466K(33216K)] 41191K-&gt;10509K(74048K), 0.0088430 secs] \[Times: user=0.02 sys=0.00, real=0.01 secs] 

2011-05-11T17:49:44.771+0800: \[GC \[PSYoungGen: 33186K-&gt;2466K(63936K)] 41229K-&gt;10509K(104768K), 0.0069690 secs] \[Times: user=0.02 sys=0.00, real=0.01 secs] 

2011-05-11T17:49:44.911+0800: \[GC \[PSYoungGen: 63906K-&gt;2482K(63936K)] 71949K-&gt;10525K(104768K), 0.0071580 secs] \[Times: user=0.02 sys=0.00, real=0.01 secs] 

2011-05-11T17:49:47.282+0800: \[GC \[PSYoungGen: 63922K-&gt;8765K(130048K)] 71965K-&gt;16807K(170880K), 0.0409860 secs] \[Times: user=0.07 sys=0.01, real=0.04 secs]