2

I'm seeing a large amount of young generation garbage collection in my application. This is a scala application running on openJDK 8u212. I did a jstat on the running docker container and it shows that the S0C area has zero size. This would explain why I would be getting so much young GC but I don't know why this is happening.

S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
 0.0   2048.0  0.0   2048.0 36864.0  31744.0   706560.0   644022.6  93360.0 82013.4 11184.0 9627.5  15299  126.920   0      0.000  126.920

Any ideas on how I can investigate this further? These are my JVM_OPTS.

"-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/mnt/mesos/sandbox/ -Xmx3g -XX:+UseG1GC -XX:+UseStringDeduplication 

I couldn't find any JVM opts I can use to control the size of S0C.

suleydaman
  • 463
  • 1
  • 7
  • 18
  • 2
    You get a Young GC when the Eden space is full. A Survivor space may get filled as a result of the GC, not the other way round. Since at each time between GC, one of the two survivor spaces can never contain objects, it’s not wrong to report it as having zero capacity. – Holger Mar 12 '20 at 18:06
  • 2
    In case of G1GC, the spaces are not fixed in memory. The G1GC divides the heap into regions, which get assigned to one of the logical spaces as needed. So the always-empty survivor space is truly not associated with actual memory regions. – Holger Mar 12 '20 at 18:41
  • 1
    what java version are you using (`UseCGroupMemoryLimitForHeap` is deprecated) and what _exact_ `GC` do you have? this matters in a proper and full answer – Eugene Mar 13 '20 at 14:45

1 Answers1

1

When eden space is full, minor garbage collection(consist of eden and survivor space) trigger. When triggered minor garbage collection, unreferenced objects(in Eden and survivor) are deleted, referenced objects age incremented and referenced objects are moved to other survivor space. Eden and Survivor space is cleared. This cycle continue until aged objects reach a certain age threshold. When objects reach a certain age threshold they are promoted from young generation to old generation. As Holger said, one of the two survivor spaces can never contain objects.

References:

Turac
  • 667
  • 1
  • 4
  • 19
  • Hmmm, so at anyone one time there is only one survivor space that is populated? That makes sense. What you don't see in my jstat result, which is because it is only one line, is that the two survivor spaces are switching. I expect that when the Eden gets full, the other survivor space should get populated after the minor GC. Instead, I am seeing a fully populated Eden and S1C and no switching - even though I am recording large amounts of minor GCs per second. – suleydaman Mar 13 '20 at 13:37
  • 2
    @suleydaman older GC algorithms truly have fixed memory regions associated with either survivor space and the switching has a meaning to them. Since G1GC assigns memory regions dynamically, the switching has no meaning anymore. There's just one survivor space and unused regions formerly assigned to a survivor space. – Holger Mar 16 '20 at 10:36