What Java Garbage Collectors cleanup PermGen?

不羁岁月 提交于 2019-12-12 12:03:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!