PermGen空间异常 [英] PermGen space exception

查看:138
本文介绍了PermGen空间异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JBoss上运行的应用程序使用JAVA 5(32位)。但它仅适用于32位。当我们在64位java5上部署它时,它抛出异常

I m using JAVA 5 (32 bit) for my application running on JBoss. But it working fine only for 32bit. As we deploy it on 64bit java5, it throws an Exception

"java.lang.OutOfMemoryError: PermGen space" exception

是否需要补丁?
是否需要更改代码?

Is there any Patch required? Is any code code change required?

提前致谢。

推荐答案

当我在tomcat或jetty下运行我的web应用程序时,我得到了同样的问题。永久生成内存用于加载类,其思路是类被永久加载。由于我使用了相当多的库和Spring框架,因此当我多次重新部署Web应用程序而不重新启动servlet容器时,这个内存很快就会填满。

I have got the same prolem when I run my web application under tomcat or jetty. Permanent genration memory is used for loading the classes and the idea is that "Classes are loaded once and forever". Since I am using quite a lot of libraries and Spring framework, this memory is filled up very quickly espectially when I redeploy the web application several time with out restarting the servlet container.

我发现增加最大永久性发电是不够的。您还需要允许垃圾收集在运行时删除未使用的类,否则它将被填满并抛出PermGen空间异常。以下是我为servlet容器添加的JVM选项,

I found that increasing the maximum permanent generation is not sufficient. You also need to allow the garbage collection to removed the unused classes at runtime, otherwise it will be filled up and throws PermGen space exception. Here are the JVM options that I added for my servlet containers,

-XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled

-XX:MaxPermSize 用于设置永久生成的最大值。这应该大于默认大小。

-XX:MaxPermSize is used to set the maximum value of permanent generation. This should be greater than the default size.

-XX:+ CMSClassUnloadingEnabled 此选项用于允许JVM在运行时卸载类。默认情况下,禁用类卸载。对于Java 5,请阅读

-XX:+CMSClassUnloadingEnabled this option is used to allows JVM to unload the class at runtime. By default, class unloading is disable. For Java 5, please read this.

-XX:+ UseConcMarkSweepGC ,为了使类上传选项起作用,还必须设置此选项( ref

-XX:+UseConcMarkSweepGC, in order for class uploading option to work, this option must also be set (ref)

此外,您应该考虑升级您的JVM版本。 Java 5太旧了。

Also, you should consider upgrading your JVM version. Java 5 is too old.

这篇关于PermGen空间异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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