当前位置:网站首页>Two fatal problems in CMS collector

Two fatal problems in CMS collector

2020-12-06 18:52:23 Entry station

CMS Is a good concurrent garbage collector , But there are two important problems in using it .

  • promotion failed Promotion failure
  • concurrent mode failure The collector cannot handle floating garbage

promotion failed The reasons for the failure of promotion

This problem occurs in Minor GC In the process , Survivor Space Can't put down the transfer object , The old generation can't let go (promotion failed It happened in the old days CMS There is no chance to recycle , I can 't put down the objects that have been transferred to the old age , The next step will be concurrent mode fialure, happen STW Downgrade to Serial Old)

Here's a line promotion failed Failure log

106.641: [GC 106.641: [ParNew (promotion failed): 14784K->14784K(14784K), 0.0370328 secs]106.678: [CMS106.715: [CMS-concurrent-mark: 0.065/0.103 secs] [Times: user=0.17 sys=0.00, real=0.11 secs]
(concurrent mode failure): 41568K->27787K(49152K), 0.2128504 secs] 52402K->27787K(63936K), [CMS Perm : 2086K->2086K(12288K)], 0.2499776 secs] [Times: user=0.28 sys=0.00, real=0.25 secs]

concurrent mode failure Cause of occurrence

concurrent mode failure yes CMS Specific mistakes , CMS The garbage cleaning thread and user thread are carried out in parallel . The older generation is cleaning up , From the younger generation to a new one , Or the allocation of large objects in the new generation can not put down , Allocate memory directly to the older generation , At this time, the old generation can't let go , It will be thrown out. concurrent mode failure

concurrent mode failure Influence

Garbage collectors in the old days started from CMS Degenerate into Serial Old, All user threads are suspended , Longer pause time .

Solution

CMS Trigger too late

-XX:CMSInitiatingOccupancyFraction=N It means setting CMS When the memory usage reaches N% At the beginning of GC( because CMS There will be floating garbage , So it's usually started earlier GC);
  • take :-XX:CMSInitiatingOccupancyFraction=N The small

There's too much space debris

Turn on space defragmentation , And set the space defragmentation cycle in a reasonable range ,- XX:CMSFullGCsBeforeCompaction effect : Set how many times to execute Full GC After the memory space compression finishing .
  • -XX:+UseCMSCompactAtFullCollection ( Space fragmentation )
  • -XX:CMSFullGCsBeforeCompaction=n

Garbage is produced too fast

  • The promotion threshold is too small
  • Survivor The space is too small
  • Eden The area is too small , It leads to too fast promotion
  • There are big objects

版权声明
本文为[Entry station]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201206185115949k.html