Hi Nico and others,

Coincidentally, we at the EO were also busy tuning our garbage collectors,
and we have a few insights to share. Credits go to Sander de Boer and Mark
Huijser also.

First of all, if you use the 1.4.2 SUN jdk, the 'jvmstat' tool from SUN
(http://developers.sun.com/dev/coolstuff/jvmstat/) is an absolute
necessity when trying to find garbage collect problems. It shows you
graphically how your memory is filled between:
- permanent generation
- old generation
- young generation
  - eden
  - survivor spaces
You can see an example on http://www.warande.net/~johannes/jvmstat.jpg
Note that in an ideal run, you want your survivor space to have objects of
different ages, that means you have enough space there to not instantly
promote live objects to the old generation. This means less pollution of
the Old generation.

The first thing we noticed is that the 'filled' survivor space was always
100% full, even with the settings provided by Nico. We are now running
SurvivorRate=4 on one of our machines with promising results. Furthermore,
we noticed that Full GC's still happened, even when the old generation has
plenty free memory. The bottleneck appeared to be the 'permanent'
generation, which was dynamically shaped and always reaching its limit.

Especially in JSP environments when a lot of classes are loaded, it is a
good practice to set the 'PermSize' value high enough. Full GCs are
needed to extend the permanent generation sometimes, and we are now
running one of our deploy server without having Full GCs at all!

Our settings:
 -XX:MaxPermSize=128M
  Make sure that there is a maximum of 128Mb of permanent storage, for
  classes, JVM allocated memory, and such.
 -XX:PermSize=64M
  Allocate at least 64M of memory for permanent storage at JVM startup.
  This removes the need for Full GCs to extend the permanent storage.
  On smaller sites this value might be smaller, but use a value of at
  least 32Mb here.
 -XX:SurvivorRatio=4
  This setting is a bit less conservative than Nico's. In our situation
  it appears to be the best one, but I suggest you use jvmstat on your
  MMBase instance to find a value that suits your site best.

Furthermore, we have the '-server -Xms -Xmx and -XX:NewSize' parameters
set, especially the last one is important to make sure you have enough
room in your Eden and survivor spaces. Use 'jvmstat' again to decide.

Johannes, Sander & Mark

Reply via email to