在catalina.sh加入 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:log/gc.log(具体位置应该都知道,set java_opts那里)
可以在/home/log下生产一个gc.log的文件 可以将此文件sz下来或者直接tail观看gc的情况。
以下是我gc.log中的一个片段
{Heap before GC invocations=1 (full 0): PSYoungGen total 917504K, used 31458K [0x00000007c0000000, 0x0000000800000000, 0x0000000800000000) eden space 786432K, 4% used [0x00000007c0000000,0x00000007c1eb8858,0x00000007f0000000) from space 131072K, 0% used [0x00000007f8000000,0x00000007f8000000,0x0000000800000000) to space 131072K, 0% used [0x00000007f0000000,0x00000007f0000000,0x00000007f8000000) ParOldGen total 1048576K, used 0K [0x0000000700000000, 0x0000000740000000, 0x00000007c0000000) object space 1048576K, 0% used [0x0000000700000000,0x0000000700000000,0x0000000740000000) PSPermGen total 131072K, used 10488K [0x00000006f0000000, 0x00000006f8000000, 0x0000000700000000) object space 131072K, 8% used [0x00000006f0000000,0x00000006f0a3e3a8,0x00000006f8000000) 0.793: [GC [PSYoungGen: 31458K->4293K(917504K)] 31458K->4301K(1966080K), 0.0087090 secs] [Times: user=0.03 sys=0.00, real=0.01 secs] Heap after GC invocations=1 (full 0): PSYoungGen total 917504K, used 4293K [0x00000007c0000000, 0x0000000800000000, 0x0000000800000000) eden space 786432K, 0% used [0x00000007c0000000,0x00000007c0000000,0x00000007f0000000) from space 131072K, 3% used [0x00000007f0000000,0x00000007f04316a0,0x00000007f8000000) to space 131072K, 0% used [0x00000007f8000000,0x00000007f8000000,0x0000000800000000) ParOldGen total 1048576K, used 8K [0x0000000700000000, 0x0000000740000000, 0x00000007c0000000) object space 1048576K, 0% used [0x0000000700000000,0x0000000700002000,0x0000000740000000) PSPermGen total 131072K, used 10488K [0x00000006f0000000, 0x00000006f8000000, 0x0000000700000000) object space 131072K, 8% used [0x00000006f0000000,0x00000006f0a3e3a8,0x00000006f8000000) }
ps:附上一张gc log的解释图 ![gc log解释][1] [1]: