-XX:+PrintGC 输出GC日志(也可以-verbose:gc)
-XX:+PrintGCDetails 输出GC的详细日志
-XX:+PrintGCTimeStamps 输出GC的时间戳(以基准时间的形式)-XX:+PrintGCDateStamps 输 出GC的时间戳(以日期的形式,如 2013-05-04T21:53:59.234+0800)
-XX:+PrintHeapAtGC 在进行GC的前后打印出堆的信息
-Xloggc:../logs/gc.log 日志文件的输出路径
Java代码
-XX:+PrintGCDetails -Xloggc:../logs/gc.log -XX:+PrintGCTimeStamps
输出:
Heap def new generation total 4928K, used 1503K [0x1c240000, 0x1c790000, 0x21790000) eden space 4416K, 34% used [0x1c240000, 0x1c3b7c68, 0x1c690000) from space 512K, 0% used [0x1c690000, 0x1c690000, 0x1c710000) to space 512K, 0% used [0x1c710000, 0x1c710000, 0x1c790000) tenured generation total 10944K, used 0K [0x21790000, 0x22240000, 0x2c240000) the space 10944K, 0% used [0x21790000, 0x21790000, 0x21790200, 0x22240000) compacting perm gen total 12288K, used 207K [0x2c240000, 0x2ce40000, 0x30240000) the space 12288K, 1% used [0x2c240000, 0x2c273ea0, 0x2c274000, 0x2ce40000) ro space 10240K, 45% used [0x30240000, 0x306c73d8, 0x306c7400, 0x30c40000) rw space 12288K, 54% used [0x30c40000, 0x312cacc8, 0x312cae00, 0x31840000)