什么是否发生youngGC、CMS过程

1.什么是否发生youngGC

1.堆内存分为年轻代和老年代,年轻代分为eden和Survivor。当eden满的是否发生young GC

2.配置jvm -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC,打印gc日志观察

19:14:04.175 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
19:14:04.178 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
19:14:04.179 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/Bairong/git/pulsar-admin/target/classes/]
[GC (Allocation Failure) [ParNew: 69952K->8704K(78656K), 0.0126571 secs] 69952K->10644K(253440K), 0.0129958 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
************分配失败发生young GC,可以修改初始堆内存减少启动时的young GC
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

19:14:04.734 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - Starting PulsarDemoApplication on BR-IT-A00966 with PID 4292 (C:\Users\Bairong\git\pulsar-admin\target\classes started by Bairong in C:\Users\Bairong\git\pulsar-admin)
19:14:04.735 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - The following profiles are active: dev
[GC (Allocation Failure) [ParNew: 78656K->8704K(78656K), 0.0226853 secs] 80596K->19359K(253440K), 0.0227187 secs] [Times: user=0.11 sys=0.02, real=0.02 secs] 
[GC (CMS Initial Mark) [1 CMS-initial-mark: 10655K(174784K)] 19365K(253440K), 0.0011289 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.006/0.006 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-abortable-preclean-start]
[CMS-concurrent-abortable-preclean: 0.169/0.631 secs] [Times: user=2.28 sys=0.44, real=0.63 secs] 
[GC (CMS Final Remark) [YG occupancy: 54326 K (78656 K)][Rescan (parallel) , 0.0035480 secs][weak refs processing, 0.0000283 secs][class unloading, 0.0043895 secs][scrub symbol table, 0.0045705 secs][scrub string table, 0.0004488 secs][1 CMS-remark: 10655K(174784K)] 64981K(253440K), 0.0137469 secs] [Times: user=0.06 sys=0.00, real=0.01 secs] 
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.004/0.004 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.029/0.029 secs] [Times: user=0.14 sys=0.02, real=0.03 secs] 
[GC (Allocation Failure) [ParNew: 78656K->8332K(78656K), 0.0070534 secs] 87362K->22632K(253440K), 0.0070940 secs] [Times: user=0.03 sys=0.02, real=0.01 secs] 
[GC (Allocation Failure) [ParNew: 78284K->7198K(78656K), 0.0214891 secs] 92584K->24321K(253440K), 0.0215893 secs] [Times: user=0.11 sys=0.01, real=0.02 secs] 
[GC (Allocation Failure) [ParNew: 77150K->8704K(78656K), 0.0107731 secs] 94273K->30014K(253440K), 0.0108127 secs] [Times: user=0.09 sys=0.02, real=0.01 secs] 
[GC (Allocation Failure) [ParNew: 78656K->6582K(78656K), 0.0073726 secs] 99966K->31241K(253440K), 0.0074060 secs] [Times: user=0.11 sys=0.01, real=0.01 secs] 
19:14:10.209 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - Started PulsarDemoApplication in 6.018 seconds (JVM running for 6.63)
[GC (Allocation Failure) [ParNew: 76534K->4751K(78656K), 0.0125111 secs] 101193K->32726K(253440K), 0.0125502 secs] [Times: user=0.06 sys=0.00, real=0.01 secs] 

3.分配失败发生young GC,可以修改初始堆内存减少启动时的young GC, -Xmx1g -Xms1g查看日志

19:20:16.386 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
19:20:16.389 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
19:20:16.389 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/Bairong/git/pulsar-admin/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.0.RELEASE)

19:20:16.887 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - Starting PulsarDemoApplication on BR-IT-A00966 with PID 22420 (C:\Users\Bairong\git\pulsar-admin\target\classes started by Bairong in C:\Users\Bairong\git\pulsar-admin)
19:20:16.888 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - The following profiles are active: dev
[GC (CMS Initial Mark) [1 CMS-initial-mark: 0K(699072K)] 234892K(1013632K), 0.0425232 secs] [Times: user=0.05 sys=0.00, real=0.04 secs] 
[CMS-concurrent-mark-start]
[CMS-concurrent-mark: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-preclean-start]
[CMS-concurrent-preclean: 0.001/0.001 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-abortable-preclean-start]
[GC (Allocation Failure) [ParNew: 279616K->32598K(314560K), 0.0226169 secs] 279616K->32598K(1013632K), 0.0226606 secs] [Times: user=0.03 sys=0.00, real=0.02 secs] 
[CMS-concurrent-abortable-preclean: 0.628/1.692 secs] [Times: user=4.26 sys=0.63, real=1.69 secs] 
[GC (CMS Final Remark) [YG occupancy: 182206 K (314560 K)][Rescan (parallel) , 0.0107916 secs][weak refs processing, 0.0000164 secs][class unloading, 0.0040240 secs][scrub symbol table, 0.0036133 secs][scrub string table, 0.0003470 secs][1 CMS-remark: 0K(699072K)] 182206K(1013632K), 0.0197032 secs] [Times: user=0.13 sys=0.00, real=0.02 secs] 
[CMS-concurrent-sweep-start]
[CMS-concurrent-sweep: 0.000/0.000 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
[CMS-concurrent-reset-start]
[CMS-concurrent-reset: 0.006/0.006 secs] [Times: user=0.06 sys=0.03, real=0.01 secs] 
19:20:20.610 [restartedMain] INFO  c.b.a.g.pulsar.PulsarDemoApplication - Started PulsarDemoApplication in 4.209 seconds (JVM running for 4.727)

4.CMS垃圾回收的阶段分为以下七个阶段,所有名字中带concurrent的阶段都是和应用程序异步的执行,不带的阶段是和应用程序异步的执行

CMS Initial Mark
CMS-concurrent-mark-start
CMS-concurrent-preclean-start
CMS-concurrent-abortable-preclean-start
CMS Final Remark
CMS-concurrent-sweep-start
CMS-concurrent-reset-start

你可能感兴趣的:(java,jvm)