I'm wondering what are the exact situations that trigger Full Garbage Collection in Java.
The obvious ones are:
- Running out of old gen
- Running out of perm gen
- Calling System.gc()
What about other cases that cause full gc? Particularly:
- Not having enough free space in Survivor Space to copy objects from Eden.
- Minor collections not being able to cope with allocation rate of new objects (don't know how though).
I'm running Sun Java 1.6 and using Concurrent Mark-Sweep and ParNew for new gen.
I've observed one more situation that triggers a full GC in Java Hotspot VM 1.6 64bit on Ubuntu, using Concurrent Mark-Sweep:
If -XX:PermSize value does not equal to -XX:MaxPermSize (e.g. is smaller), an occasional Full GC happens when java needs to expand the PermGen (even though it does not need to allocate more memory than MaxPermSize).
So setting -XX:PermSize and -XX:MaxPermSize to be the same seems like a good idea.
This greatly depends on your jvm options and the jvm that you at using.
For this reason, I recommend that you look at the book "Java Performance" bý John and Hunt.