package com.jvm.jvmdemo.test;
/**
* @author :miaoqs
* @date :2019-10-30 09:58
* @description:
*/
public class GCParallelLogsTest {
/**
* 1M容量
*/
private static int size = 1024 * 1024;
public static void main(String[] args) {
byte[] a1, a2, a3, a4;
a1 = new byte[4 * size];
a1 = new byte[3 * size]; // 之前的 a1 = 4M 变成垃圾
a2 = new byte[4 * size];
// GC
a3 = new byte[4 * size]; // 当要添加 a3时发生GC 新生代 11M -> 7M
a4 = new byte[8 * size];
a4 = null; // a4变成垃圾
// FULL GC
System.gc();
}
/**
* TODO VM options 以下两行为运行参数
* -Xms40M -Xmx40M -Xmn20M -XX:+PrintGCDetails -XX:+PrintGCDateStamps
* -XX:+UseParallelGC
*
*
* TODO 开发人员可通过-XX:+UseParallelGC 启用 Parallel GC,
* 此时,年轻代将使用标记-复制(mark-copy)算法,
* 老年代使用标记- 清理-压缩(mark-sweep-compact)算法,
* 并且均以多线程,stop-the-world 的方式运行垃圾收集过程,
* 还可通过 -XX:ParallelGCThreads=N 来指定运行垃圾收集过程的线程数,默认为 CPU 核数。
* Parallel GC 收集器将有效提升应用吞吐量,也常 被称为吞吐量收集器。
*
* TODO PSYoungGen 回收的新生代的
* [GC (Allocation Failure) [PSYoungGen: 15029K->911K(17920K)]
* 15029K->8079K(38400K), 0.0045152 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
* TODO 解释
* [PSYoungGen: 15029K->911K(17920K)] 新生代内存变化 由 11M 到 0M
* 15029K->8079K(38400K) 堆内存变化 由 11M 变化为 7M
*
* TODO 以下两个 当在执行FULL GC之前会执行一次普通的GC
* [GC (System.gc()) [PSYoungGen: 13807K->704K(17920K)]
* 20975K->11976K(38400K), 0.0025829 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
* TODO 解释
* [PSYoungGen: 13807K->704K(17920K)] 新生代内存变化 12M到 0M
* 20975K->11976K(38400K) 堆内存由19M 到 12M
* [Full GC (System.gc())
* [PSYoungGen: 704K->0K(17920K)] TODO 新生代完全清空
* [ParOldGen: 11272K->11830K(20480K)] TODO 老年代变化 11M
* 11976K->11830K(38400K), TODO 堆内存变化 11M
* [Metaspace: 3224K->3224K(1056768K)], 0.0087629 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
*
* TODO GC后的堆内存情况
* Heap
* TODO 年轻代 使用0M
* PSYoungGen total 17920K, used 307K [0x00000007bec00000, 0x00000007c0000000, 0x00000007c0000000)
* eden space 15360K, 2% used [0x00000007bec00000,0x00000007bec4ce50,0x00000007bfb00000)
* from space 2560K, 0% used [0x00000007bfd80000,0x00000007bfd80000,0x00000007c0000000)
* to space 2560K, 0% used [0x00000007bfb00000,0x00000007bfb00000,0x00000007bfd80000)
*
* TODO 年老代 老年代变为 11M
* ParOldGen total 20480K, used 11830K [0x00000007bd800000, 0x00000007bec00000, 0x00000007bec00000)
* object space 20480K, 57% used [0x00000007bd800000,0x00000007be38d800,0x00000007bec00000)
*
* TODO 元空间
* Metaspace used 3230K, capacity 4556K, committed 4864K, reserved 1056768K
* class space used 346K, capacity 392K, committed 512K, reserved 1048576K
*/
}
JDK8垃圾回收GC日志分析【第二篇】
猜你喜欢
转载自blog.csdn.net/wildwolf_001/article/details/102842594
今日推荐
周排行