问题
List of Garbage Collectors:
- Serial GC
- Parallel GC
- Parallel Old GC
- Conc Mark Sweep GC
- G1 GC
I know that the Conc Mark Sweep GC supports cleaning up PermGen when you enable the ClassUnloading JVM option. Do other Garbage Collectors support cleaning up PermGen?
Reason: We use Spring, Hibernate, and Groovy that create a lot of Proxies and Perm Gen gets big.
Edit: Should have mentioned that I am using Java 7. I'm aware of Java 8 removing Perm Gen and hopefully will upgrade sometime in the future. In the meantime, my question is regarding if the other garbage collectors support cleaning up PermGen other than Conc Mark Sweep.
- Serial GC
- Parallel GC (Believe -server uses this by default and confirmed that it cleans up perm gen)
- Parallel Old GC
- Conc Mark Sweep GC (Can clean perm gen using JVM flag)
- G1 GC
回答1:
All algorithms are cleaning PermGen, but
- not every GC cycle include PermGen cleaning
- CMS can clean PermGen concurrently, G1 have been requiring stop-the-world Full GC to unload classes (clean PermGen) until Java 8u40
- Java 8 have metaspace instead of PermGen, but it needs to be garbage collected too (otherwise you'll get OOME in metaspace)
I have been fighting OOME in PermGen quite a lot when I was actively used ClassLoaders to simulate multiple JVM in single process for test purposes. My conclusion: PermGen GC is just not very reliable. One run it works as expected, other it throws OOEM.
来源:https://stackoverflow.com/questions/28433553/what-java-garbage-collectors-cleanup-permgen