java Tomcat:OutOfMemoryError Permgen Space

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15487702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 19:45:35  来源:igfitidea点击:

Tomcat: OutOfMemoryError Permgen Space

javatomcatlog4jquartz-schedulerpermgen

提问by nashuald

I am developing a JSP application using Tomcat 6.

我正在使用 Tomcat 6 开发 JSP 应用程序。

Since I did add Quartz Scheduler Framework and Log4J library to project, Tomcat start throwing this exception when redeploying.

由于我确实在项目中添加了 Quartz Scheduler Framework 和 Log4J 库,因此重新部署时 Tomcat 开始抛出此异常。

I have readed about the problem causes, and now I know that have to be with the class loader.

我已经阅读了有关问题的原因,现在我知道必须与类加载器有关。

So, I guess the problem can be caused by the logger library that load some classes automatically.

所以,我猜这个问题可能是由自动加载一些类的记录器库引起的。

How can I deal with this problem? There is alternative way to setup the logger without using the log4j.properties file to ensure that classloader will work correctly.

我该如何处理这个问题?有另一种方法可以在不使用 log4j.properties 文件的情况下设置记录器,以确保类加载器正常工作。

回答by Lan

One way is to increase your permgen space by adding the following JVM arguments to below

一种方法是通过在下面添加以下 JVM 参数来增加 permgen 空间

-XX:MaxPermSize=256m

But it will only delay the OOM error. If you do redeployment again and again, you will run into the permgen out of memory again. The reason is explained very clearly in this article, which I won't repeat here. http://frankkieviet.blogspot.com/2006/10/classloader-leaks-dreaded-permgen-space.html. Sorry I do not have a different way to setup the logger differently to avoid this issue. In practice, I always increase the MaxPermSize and then cycle server before deployment.

但是只会延迟OOM错误。如果您一次又一次地重新部署,您将再次遇到 permgen 内存不足。原因在这篇文章中已经讲的很清楚了,这里不再赘述。http://frankkieviet.blogspot.com/2006/10/classloader-leaks-dreaded-permgen-space.html。抱歉,我没有其他不同的方法来设置不同的记录器来避免这个问题。在实践中,我总是增加 MaxPermSize,然后在部署之前循环服务器。