//java 开发环境,使用HotSpot的虚拟机,64位,windows 开发环境
Java HotSpot(TM) 64-Bit Server VM (25.151-b12) for windows-amd64 JRE (1.8.0_151-b12), built on Sep 5 2017 19:33:46 by "java_re" with MS VC++ 10.0 (VS2010)
//初始内存:4k/页,物理内存(8g--本机内存,2g空闲),交换区(9.4g,1.7g空闲)
Memory: 4k page, physical 8270992k(2282388k free), swap 9889848k(1844640k free)
//启动参数:初始化对内存126m(物理内存1/64),最大堆内存2g(物理内存1/4),打印gc日志,打印gc原因,打印gc日期戳
CommandLine flags: -XX:InitialHeapSize=132335872 -XX:MaxHeapSize=2117373952 -XX:+PrintGC -XX:+PrintGCCause -XX:+PrintGCDateStamps -
//打印gc详情 打印gc时间戳,压缩类对象实例,压缩类指针,使用大页内存
XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -
//使用Parallel 垃圾回收器
XX:+UseParallelGC
//时间 ,gc(内存分配失败)(使用Parallel Scavenge)新生代 ,内存大小从33280K变成了5107K,新生代内存大小38400K。老年代从33280K变成了5186K,新生代使用时间0.0087103 秒,一共使用时间0.01秒
2021-02-18T11:58:31.364+0800: 2.712: [GC (Allocation Failure) [PSYoungGen: 33280K->5107K(38400K)] 33280K->5186K(125952K), 0.0087103 secs] [Times: user=0.01 sys=0.01, real=0.01 secs]
2021-02-18T11:58:32.266+0800: 3.613: [GC (Allocation Failure) [PSYoungGen: 38387K->5119K(38400K)] 38466K->6115K(125952K), 0.0090626 secs] [Times: user=0.06 sys=0.00, real=0.01 secs]
2021-02-18T11:58:33.041+0800: 4.388: [GC (Allocation Failure) [PSYoungGen: 38399K->5107K(38400K)] 39395K->8534K(125952K), 0.0566775 secs] [Times: user=0.16 sys=0.00, real=0.06 secs]
2021-02-18T11:58:34.392+0800: 5.740: [GC (Allocation Failure) [PSYoungGen: 38387K->5098K(71680K)] 41814K->10989K(159232K), 0.0214275 secs] [Times: user=0.08 sys=0.00, real=0.02 secs]
//元空间gc,达到了元空间的阈值,(使用Parallel Scavenge)新生代,从34271K变成了5112K(内存大小71680K);老年代,从40162K变成了12982K(内存大小159232K),新生代使用时间0.0178599秒,共使用0.06 秒(可以看出,这里元空间的gc时间,是新生代2.5倍)
2021-02-18T11:58:35.110+0800: 6.457: [GC (Metadata GC Threshold) [PSYoungGen: 34271K->5112K(71680K)] 40162K->12982K(159232K), 0.0178599 secs] [Times: user=0.06 sys=0.00, real=0.02 secs]
//full gc,包括新生代、老年代、元空间(永久代,放在方法区里,主要存放类新信息、方法信息等),达到了元空间的阈值,(使用Parallel Scavenge)新生代,从5112K变成了0K(内存大小71680K,完全回收);老年代(使用了ParOld,Parallel Scavenge老年代版本 垃圾回收器),从7870K变成了7740K(内存大小56320K),新生代使用时间0.0790402 秒,共使用0.27 秒(可以看出,这里元空间的gc时间,是新生代的3倍))
2021-02-18T11:58:35.128+0800: 6.475: [Full GC (Metadata GC Threshold) [PSYoungGen: 5112K->0K(71680K)] [ParOldGen: 7870K->7740K(56320K)] 12982K->7740K(128000K), [Metaspace: 20885K->20885K(1069056K)], 0.0790402 secs] [Times: user=0.27 sys=0.00, real=0.08 secs]
2021-02-18T11:58:36.444+0800: 7.792: [GC (Allocation Failure) [PSYoungGen: 66560K->5518K(113152K)] 74300K->13267K(169472K), 0.0080603 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2021-02-18T11:58:38.382+0800: 9.732: [GC (Allocation Failure) [PSYoungGen: 113038K->8692K(138752K)] 120787K->17655K(195072K), 0.0214940 secs] [Times: user=0.05 sys=0.01, real=0.02 secs]
2021-02-18T11:58:43.737+0800: 15.085: [GC (Metadata GC Threshold) [PSYoungGen: 130761K->10222K(177664K)] 139723K->24379K(233984K), 0.0210900 secs] [Times: user=0.11 sys=0.03, real=0.02 secs]
2021-02-18T11:58:43.759+0800: 15.107: [Full GC (Metadata GC Threshold) [PSYoungGen: 10222K->0K(177664K)] [ParOldGen: 14156K->21200K(92672K)] 24379K->21200K(270336K), [Metaspace: 34810K->34810K(1081344K)], 0.1114812 secs] [Times: user=0.61 sys=0.02, real=0.11 secs]
2021-02-18T11:58:45.481+0800: 16.829: [GC (Allocation Failure) [PSYoungGen: 167424K->9056K(180736K)] 188624K->30264K(273408K), 0.0126356 secs] [Times: user=0.02 sys=0.02, real=0.01 secs]
2021-02-18T11:58:47.195+0800: 18.542: [GC (Allocation Failure) [PSYoungGen: 176480K->11091K(229888K)] 197688K->32308K(322560K), 0.0190669 secs] [Times: user=0.02 sys=0.02, real=0.02 secs]
---------额外连接,gc的算法:
https://blog.csdn.net/high2011/article/details/80177473
------额外连接,gc优化方案