JVM忽略GC日志记录标志



我正在运行一个带有标志-Xloggc:./gc-$$.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps的简单程序,它的所有输出都是

Heap
 def new generation   total 4928K, used 642K [0x04760000, 0x04cb0000, 0x09cb0000)
  eden space 4416K,  14% used [0x04760000, 0x04800b38, 0x04bb0000)
  from space 512K,   0% used [0x04bb0000, 0x04bb0000, 0x04c30000)
  to   space 512K,   0% used [0x04c30000, 0x04c30000, 0x04cb0000)
 tenured generation   total 10944K, used 0K [0x09cb0000, 0x0a760000, 0x14760000)
   the space 10944K,   0% used [0x09cb0000, 0x09cb0000, 0x09cb0200, 0x0a760000)
 compacting perm gen  total 12288K, used 1588K [0x14760000, 0x15360000, 0x18760000)
   the space 12288K,  12% used [0x14760000, 0x148ed008, 0x148ed200, 0x15360000)
No shared spaces configured.

(我也尝试过添加-verbose:gc

我想得到实际的GC统计数据,比如:

581.146: [Full GC [PSYoungGen: 170752K->0K(341376K)] [PSOldGen: 786611K->786713K(919552K)] 957363K->786713K(1260928K) [PSPermGen: 19076K->19076K(29184K)], 3.4611450 secs] 
584.691: [Full GC [PSYoungGen: 170752K->0K(341376K)] [PSOldGen: 786713K->786759K(919552K)] 957465K->786759K(1260928K) [PSPermGen: 19076K->19076K(27648K)], 3.4172340 secs] 

找不到我做错了什么。我使用

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode

错误的标志?

您的标志看起来不错。该程序触发了不同的输出:

class Foo {
  public static void main(String[] args) { System.gc(); }
}

在日志文件中有输出,如

2014-05-10T01:20:41.896+0200: 0.054: [GC (System.gc()) [PSYoungGen: 379K->352K(1024K)] 379K->360K(128512K), 0.0007776 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 

好吧,apangin做对了——我的gc没有足够的时间运行。让程序运行的时间长了一点,我得到了propper日志。

最新更新