Avoiding Promotion Failed in Java CMS GC

I have a Java application that uses CMS garbage collection that suffers several times a day from “ParNew's complete failure (promotion)” (see example below). I understand that advertising crashes when garbage collection cannot find enough (adjacent) space in the old generation into which an object from a new generation can be promoted. At this point, she is forced to make an expensive full global GC. I want to avoid such events.

I read several articles that offer possible solutions, but I would like to clarify / generalize them here:

  • -Xmx: Increase heap size, for example. from 2G to 4G - a simple solution providing great bandwidth in the old generation - seems to work well in my experience
  • -XX: NewRatio: Enlarge NewRatio, for example. from 2 to 4, to increase the old generation / reduce the new generation - give the old generation more space - does not seem to have much effect, if any, from my experiments so far
  • -XX: PromotedPadding: Increase the number of add-ons provided to prevent glitches in the promotion - however, I cannot find any suggestions about what values ​​should be specified for this parameter. Does anyone know what a value means, what is the default, or what values ​​to try?
  • -XX: CMSInitiatingOccupancyFraction -XX: + UseCMSInitiatingOccupancyOnly: Run the CMS cycle earlier to avoid running out of space in the old generation - I have not tried this solution yet - what values ​​would be reasonable to try? What is the default?
  • : , - ,

, , GC , .

-Xmx4g -XX:+UseConcMarkSweepGC -XX:NewRatio=1

2014-12-19T09:38:34.304+0100: [GC (Allocation Failure) [ParNew: 1887488K->209664K(1887488K), 0.0685828 secs] 3115998K->1551788K(3984640K), 0.0690028 secs] [Times: user=0.50 sys=0.02, real=0.07 secs] 
2014-12-19T09:38:35.962+0100: [GC (Allocation Failure) [ParNew: 1887488K->208840K(1887488K), 0.0827565 secs] 3229612K->1687030K(3984640K), 0.0831611 secs] [Times: user=0.39 sys=0.03, real=0.08 secs] 
2014-12-19T09:38:39.975+0100: [GC (Allocation Failure) [ParNew: 1886664K->114108K(1887488K), 0.0442130 secs] 3364854K->1592298K(3984640K), 0.0446680 secs] [Times: user=0.31 sys=0.00, real=0.05 secs] 
2014-12-19T09:38:44.818+0100: [GC (Allocation Failure) [ParNew: 1791932K->167245K(1887488K), 0.0588917 secs] 3270122K->1645435K(3984640K), 0.0593308 secs] [Times: user=0.57 sys=0.00, real=0.06 secs] 
2014-12-19T09:38:49.239+0100: [GC (Allocation Failure) [ParNew (promotion failed): 1845069K->1819715K(1887488K), 0.4417916 secs][CMS: 1499941K->647982K(2097152K), 2.4203021 secs] 3323259K->647982K(3984640K), [Metaspace: 137778K->137778K(1177600K)], 2.8626552 secs] [Times: user=3.46 sys=0.01, real=2.86 secs] 
+4
2

, , , , . GC , :

GC (CMS Initial Mark) [1 CMS-initial-mark: 2905552K(3145728K)]

, 92% CMS ( 2,9 3,1 ). , JVM , " " 90%. , , , , 68%.

-, , JVM , . , , JVM, , .

GC

-XX:CMSInitiatingOccupancyFraction=50 -XX:+UseCMSInitiatingOccupancyOnly

- " ". , , 50% JVM . , 50%, CMS. , 90% , " " .

+6

- . - , ( ) 2,5x, , GC.

GC CMS , , .

, .

- . , , , , .

+1

Source: https://habr.com/ru/post/1568600/


All Articles