PermGen 空间异常 [英] PermGen space exception

查看:19
本文介绍了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,为了使类上传选项起作用,还必须设置此选项(参考)

-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天全站免登陆