简体   繁体   English

PermGen空间内存泄漏

[英]PermGen space Memory leak

org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet default threw exception

java.lang.OutOfMemoryError: PermGen space

I am getting this error when deploying the application and server is hanging after 15 to 20 min. 15到20分钟后,部署应用程序且服务器挂起时出现此错误。

There could be a very specific reason why PermGen error is being produced. 产生PermGen错误的原因可能非常具体。 But.. 但..

Allocate more space to the tomcat JVM with ( in the JAVA_OPTS) 用(在JAVA_OPTS中)为tomcat JVM分配更多空间

-XX:MaxPermSize=256m

or whatever size you want. 或任何您想要的尺寸。

Do take a look at http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/ 请看一下http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/

Solution is to increase PermGen heap size in catalina.bat of tomcat server; 解决方案是增加tomcat服务器的catalina.batPermGen堆大小; this can give you some breathing space but eventually this will also return in java.lang.OutOfMemoryError: PermGen space after some time. 这可以为您提供一些喘息的空间,但是一段时间之后,最终它还会在java.lang.OutOfMemoryError: PermGen空间中返回。

Follow these steps to increase the PermGen Heap size:

1) Go to Tomcat installation directory i.e C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.14\bin in Windows.

2) Add JAVA_OPTS in your catalina.bat

set JAVA_OPTS="-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m"

Increasing PermGen space can prevent java.lang.OutOfMemoryError: PermGen in tomcat only for some time and it will eventually occur based on how many times you redeploy your web application, its best to find the offending class which is causing memory leak in tomcat and fix it. 增加PermGen空间可以防止java.lang.OutOfMemoryError: PermGen Tomcat中的java.lang.OutOfMemoryError: PermGen只能使用一段时间,并且最终会根据您重新部署Web应用程序的次数而发生,最好是找出有问题的类,该类会导致tomcat中的内存泄漏并修复它。

When you have a memory leak, it signals that you have a Permanent Generation leak in your application, what means that whenever you redeploy an application in your application server it leaves a whole lot of classes behind. 当您遇到内存泄漏时,表明您的应用程序中存在永久世代泄漏,这意味着每当您在应用程序服务器中重新部署应用程序时,都会留下很多类。 These old class definitions end up in your JVM permanent generation, eating up precious memory therefore the solution is never to increase Permgen size, this "solution" is a time bomb. 这些旧的类定义最终出现在您的JVM永久代中,耗尽了宝贵的内存,因此解决方案永远不会增加Permgen的大小,这个“解决方案”就是一颗定时炸弹。

As is also the case with other types of memory leaks, there is no golden tool or a fixed how-to list that you can follow to magically solve the problem. 与其他类型的内存泄漏一样, 也没有黄金工具固定的操作列表可用来神奇地解决问题。 There are many possible cases and many ways to solve it. 有很多可能的情况和解决方法。

Having said that I recommend to use Plumbr ( official website ) and here you have a very usefulguide to solve it : 话虽如此,我建议您使用Plumbr官方网站 ),在这里您可以找到非常有用的解决方法

Solving run-time OutOfMemoryError 解决运行时OutOfMemoryError

Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM