本文介绍了哪些Java垃圾收集器清理PermGen?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

垃圾收集者列表:

  • 串行GC
  • 平行GC
  • 并行旧GC
  • 浓缩标记扫描GC
  • G1 GC

我知道,当您启用ClassUnloading JVM选项时,Conc Mark Sweep GC支持清理PermGen.其他垃圾收集器是否支持清理PermGen?

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?

原因:我们使用Spring,Hibernate和Groovy创建大量代理,并且Perm Gen变大.

Reason: We use Spring, Hibernate, and Groovy that create a lot of Proxies and Perm Gen gets big.

应该提到我正在使用Java7.我知道Java 8删除了Perm Gen,希望在将来的某个时候进行升级.同时,我的问题是关于其他垃圾收集器是否支持清理Conm Mark Sweep以外的PermGen.

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.

  • 串行GC
  • 并行GC(默认情况下,Believe -server使用它并确认它清除了perm gen)
  • 并行旧GC
  • Conc Mark Sweep GC(可以使用JVM标志清除perm gen)
  • G1 GC

推荐答案

所有算法都在清理PermGen,但是

All algorithms are cleaning PermGen, but

  • 并非每个GC周期都包括PermGen清洁
  • CMS可以同时清理PermGen,G1一直要求停止运行的完整GC 卸载类(清理PermGen),直到Java 8u40
  • Java 8具有元空间而不是PermGen,但是它也需要进行垃圾收集(否则,您将在元空间中获得OOME)
  • 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)

当我出于测试目的而积极地使用ClassLoader在单个进程中模拟多个JVM时,我在PermGen中与OOME进行了很多斗争.我的结论是:PermGen GC并不是很可靠.一种运行符合预期,另一种运行则抛出OOEM.

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.

这篇关于哪些Java垃圾收集器清理PermGen?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:04