Java垃圾收集器(G1GC)中的类卸载 [英] Class Unloading in Java's G1 Garbage Collector (G1GC)

查看:1064
本文介绍了Java垃圾收集器(G1GC)中的类卸载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java 6中,我们使用以下GC配置来防止Perm Gen OutOfMemoryException 在多次重新部署我们的应用程序后:

-XX:+ UseConcMarkSweepGC -XX:+ CMSClassUnloadingEnabled



我们正在转向Java 7,想要使用我读过的新的G1 GC,将Java中内存的PermGen类移动到本机内存中。



是否有一些标志使卸载未使用的类成为可能?

解决方案

G1在完整GC期间执行类卸载,因此您无需指定任何参数即可启用该功能。

您可以使用 -XX:+ TraceClassUnloading 参数来查看自己。

另外,请从HotSpot GC邮件列表中查看此电子邮件主题: G1GC存在Bug,当代码缓存已满时执行Full GC,导致过度杀毒。他们相当广泛地讨论G1级的卸载问题。总而言之,如果您发现类卸载有问题,则可以使用 -noclassgc ,但通常在G1中没有类卸载问题。


In Java 6 we used to use the following GC configuration to prevent Perm Gen OutOfMemoryException after several redeployments of our app:

-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled

We're moving to Java 7 and want to use the new G1 GC, which from what I've read, moves the classes from the PermGen in Java memory to native memory.

Is there some flag to enable unloading unused classes?

解决方案

The G1 performs the class unloading during a Full GC, so you do not need to specify any parameters to enable this.

You can see for yourself by using the -XX:+TraceClassUnloading argument.

Also, check out this email thread from the HotSpot GC mailing list: Bug in G1GC it performs Full GC when code cache is full resulting in overkill. They discuss class unloading in G1 quite extensively. In summary, you can use -noclassgc if you are seeing issues with class unloading but usually there are no problems with class unloading in G1.

这篇关于Java垃圾收集器(G1GC)中的类卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆