4

Below is a jstat output from a JVM running with the following parameters

-Xmx10240m -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode 

The jstat output is with the parameters

jstat -gcutil <pid> 10s

The section is snippet over a period of 80 seconds and according to the statistics nearly 70 seconds of this is spend in GC. They are all full GCs that are being triggered.

Timestamp   S0  S1  E       O       P       YGC     YGCT        FGC     FGCT        GCT         Diff
1040430.2   0   0   23.69   24.58   95.03   168048  22187.057   3672    4483.931    26670.988   8.175
1040440.2   0   0   0.1     24.58   95.02   168048  22187.057   3674    4495.551    26682.608   11.62
1040450.2   0   0   4.19    24.59   95.03   168048  22187.057   3677    4506.731    26693.788   11.18
1040460.2   0   0   0.01    24.45   95.02   168048  22187.057   3679    4517.391    26704.448   10.66
1040470.2   0   0   0.33    24.45   95.03   168048  22187.057   3681    4522.213    26709.27    4.822
1040480.2   0   0   0       24.43   95.02   168048  22187.057   3684    4534.816    26721.874   12.604

The PermGen space is running at almost full but I didn't think that the Sun GC mechanism will attempt to collect here and I can see a reason for collected based on the Eden or Old space.

Anyone able to give me some pointers are to what might be occuring?

bstick12
  • 1,699
  • 12
  • 18

1 Answers1

3

Why is the JVM doing so many garbage collections.

This is most likely because the permanent generation occupancy is quite high. When using the CMS algorithm, a major collection kicks in only when the old or permanent generations occupancy exceeds a defined threshold. The default occupancy threshold for the old generation is 68% unless I am mistaken, and this can be changed using the -XX:CMSInitiatingOccupancyFraction=n flag. However, in the context of the data presented, this value appears to be immaterial as the occupancy of the old generation appears to be under 25% when the statistics were taken (this does not mean that the old generation did not fill up in the interim, but it is unlikely when the permanent generation itself is exhibiting higher occupancy).

Note that the CMS collector does not claim objects from the permanent generation by default. This would require switching on the CMSClassUnloading flag. If the behavior does not improve, then it is likely that the permanent generation is not sized correctly, and it would have to be given more memory, for it would be apparent that only few of the objects in the permanent generation are eligible for collection on every major collection cycle.

Community
  • 1
  • 1
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
  • Can you please point me a the documentation that states that the PermGen will be collected by the CMS algorithm? I've been unable to see that this is the case without the flag CMSPermGenSweepingEnabled being specifically set – bstick12 Jul 11 '11 at 09:31
  • `CMSPermGenSweepingEnabled` appears to have been deprecated in Java 6. Nevertheless, most people use `CMSClassUnloadingEnabled` and `CMSPermGenSweepingEnabled` to enable collection of permgen in Java 6. The closest I could come to documentation on this behavior is the [OpenJDK mailing list](http://mail.openjdk.java.net/pipermail/hotspot-gc-dev/2008-October/000522.html) and in the Sun bug database [for bugs 5037027](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5037027) and [6250214](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6250214) – Vineet Reynolds Jul 11 '11 at 10:03
  • Accepting the answer as this does seem to the be most logical explanation. The documentation is this area is very poor. – bstick12 Jul 11 '11 at 10:07
  • 1
    Yes, the docs are poor. Most folks get to know of the flags by going through the sources of OpenJDK (which is related to the Sun/Oracle JVM). – Vineet Reynolds Jul 11 '11 at 10:09