深入理解JVM(学习过程) (40)

确定了一个待研究的主题,对这个主题进行全方面的剖析。高注意力的研究一个主题。

G1回收器日志内容详细分析 VM options: -verbose:gc -Xms10m -Xmx10m -XX:+UseG1GC //使用G1的垃圾回收器 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:MaxGCPauseMillis=200 // 指定最大的回收时间 public class MyTest1 { public static void main(String[] args) { int size = 1024 * 1024; // 1M 的容量 byte[] myAlloc1 = new byte[size]; // 创建之后每一个元素都是0 byte[] myAlloc2 = new byte[size]; // 创建之后每一个元素都是0 byte[] myAlloc3 = new byte[size]; // 创建之后每一个元素都是0 byte[] myAlloc4 = new byte[size]; // 创建之后每一个元素都是0 System.out.println("hello world "); } } > 使用G1之后的打印内容 > Task :MyTest1.main() 2020-02-21T05:25:01.316-0800: [GC pause (G1 Humongous Allocation) (young) (initial-mark), 0.0012901 secs] // 针对于年轻代的GC的5个阶段 [Parallel Time: 0.7 ms, GC Workers: 13] // 有13个线程进行回收 [GC Worker Start (ms): Min: 65.2, Avg: 65.3, Max: 65.3, Diff: 0.1] [Ext Root Scanning (ms): Min: 0.2, Avg: 0.3, Max: 0.5, Diff: 0.3, Sum: 4.4]//1.根扫描 [Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]//2.更新RS。 记忆集合 [Processed Buffers: Min: 0, Avg: 0.0, Max: 0, Diff: 0, Sum: 0] //3.处理RS [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0] [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]//跟扫描时间 [Object Copy (ms): Min: 0.1, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 1.7]//4.对象拷贝的时间 [Termination (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]//5.处理引用队列 [Termination Attempts: Min: 1, Avg: 2.3, Max: 5, Diff: 4, Sum: 30] // 下边三行,总结性的信息 [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.4] [GC Worker Total (ms): Min: 0.4, Avg: 0.5, Max: 0.6, Diff: 0.1, Sum: 6.5] [GC Worker End (ms): Min: 65.8, Avg: 65.8, Max: 65.8, Diff: 0.0] [Code Root Fixup: 0.0 ms] [Code Root Purge: 0.0 ms] [Clear CT: 0.1 ms] // CT: care table 卡表 [Other: 0.4 ms] [Choose CSet: 0.0 ms] //选择 回收集合 [Ref Proc: 0.2 ms] //引用的处理时间 [Ref Enq: 0.0 ms] [Redirty Cards: 0.1 ms] [Humongous Register: 0.0 ms] [Humongous Reclaim: 0.0 ms] [Free CSet: 0.0 ms] [Eden: 1024.0K(6144.0K)->0.0B(2048.0K) Survivors: 0.0B->1024.0K Heap: 2663.2K(10240.0K)->2640.1K(10240.0K)] //执行完一个young GC之后的结果汇总。 Eden全部被清空。 一个对象进入Survivors [Times: user=0.00 sys=0.00, real=0.00 secs] // 并发处理的过程 (比老师学习视频中的过程,少了一次年轻代的收集) 2020-02-21T05:25:01.317-0800: [GC concurrent-root-region-scan-start] 2020-02-21T05:25:01.318-0800: [GC concurrent-root-region-scan-end, 0.0002879 secs] 2020-02-21T05:25:01.318-0800: [GC concurrent-mark-start] 2020-02-21T05:25:01.318-0800: [GC concurrent-mark-end, 0.0000480 secs] 2020-02-21T05:25:01.318-0800: [GC remark 2020-02-21T05:25:01.318-0800: [Finalize Marking, 0.0002741 secs] 2020-02-21T05:25:01.318-0800: [GC ref-proc, 0.0000487 secs] 2020-02-21T05:25:01.318-0800: [Unloading, 0.0003851 secs], 0.0008481 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] 2020-02-21T05:25:01.319-0800: [GC cleanup 4688K->4688K(10240K), 0.0004242 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] hello world Heap // G1总的大小是10240K garbage-first heap total 10240K, used 4688K [0x00000007bf600000, 0x00000007bf700050, 0x00000007c0000000) // Region size 的初始大小为 1024k region size 1024K, 2 young (2048K), 1 survivors (1024K) // 元空间的大小 Metaspace used 2805K, capacity 4486K, committed 4864K, reserved 1056768K class space used 291K, capacity 386K, committed 512K, reserved 1048576K

两个问题。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpfdfy.html