JVM GC分析方式

来源:互联网 发布:安卓人肉软件 编辑:程序博客网 时间:2024/06/07 11:51

转自:http://m.oschina.net/blog/133510

JVM 参数:-Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8,新生代共计10M(Eden区10×8/(8+1+1),From+To区10×1/(8+1+1)),Tenured区共计10M,Perm区另计。

代码:

    public static void testAllocation(){          byte[] allocation1, allocation2,allocation3 ,allocation4;         allocation1 = new byte [2 * _1MB];         allocation2 = new byte [2 * _1MB];         allocation3 = new byte [2 * _1MB];         allocation4 = new byte [4 * _1MB];         System.out.println("End");   }    public static void main(String[] args) {          testAllocation();   }

GC日志输出:

[GC [DefNew: 6487K->156K(9216K), 0.0030537 secs] 6487K->6300K(19456K), 0.0030749 secs] [Times: user=0.00 sys=0.02, real=0.00 secs] 

--DefNew,新生代使用Serial回收算法,共计9216K,本次回收后新生代占用堆大小由6487K缩减为156K;新生代+年老代共计19456K,本次回收后两者相加占用堆大小由6487K缩减为6300K。其中有6300K - 156K = 6144K移入年老区。
End
Heap
 def new generation   total 9216K, used 4666K [0x32d30000, 0x33730000, 0x33730000)
  eden space 8192K,  55% used [0x32d30000, 0x33197800, 0x33530000)

--Eden区共计8192K,55%已经占用(包含allocation4以及其他JVM运行必须的class)。该区在内存中低地址位是0X32d30000,高地址位是0x33530000,已占用水平位为0x33197800。
  from space 1024K,  15% used [0x33630000, 0x336571b8, 0x33730000)

--其他JVM运行必须的class,由于from区大小不足以容纳allocation1/allocation2/allocation3,直接进入了年老区。
  to   space 1024K,   0% used [0x33530000, 0x33530000, 0x33630000)
 tenured generation   total 10240K, used 6144K [0x33730000, 0x34130000, 0x34130000)
   the space 10240K,  60% used [0x33730000, 0x33d30030, 0x33d30200, 0x34130000)

--年老区共计10240K大小,60%即6144K已占用,即本次GC被移入年老区的三个对象(allocation1/allocation2/allocation3)大小。
 compacting perm gen  total 12288K, used 371K [0x34130000, 0x34d30000, 0x38130000)
   the space 12288K,   3% used [0x34130000, 0x3418cf10, 0x3418d000, 0x34d30000)
    ro space 10240K,  54% used [0x38130000, 0x386aeb78, 0x386aec00, 0x38b30000)
    rw space 12288K,  55% used [0x38b30000, 0x391d49c8, 0x391d4a00, 0x39730000)


GC统计

[hadoop@DEV ~]$ jstat -gcutil 28893 5000 10
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
 37.07   0.00  13.67  76.72  60.30  77534  216.104 200097 20785.026 21001.130
 
S0: From区已使用的占当前容量百分比
S1: To区已使用的占当前容量百分比
E: Eden区已使用的占当前容量百分比
O: Tenured区已使用的占当前容量百分比
P: Perm区已使用的占当前容量百分比
YGC: 程序启动到采样时年轻代中gc次数
YGCT: 程序启动到采样时年轻代中gc所用时间(s)
FGC: 程序启动到采样时old代(全gc)gc次数
FGCT: 程序启动到采样时old代(全gc)gc所用时间(s)
GCT: 程序启动到采样时gc用的总时间(s)



0 0