简体   繁体   中英

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.

There could be a very specific reason why PermGen error is being produced. But..

Allocate more space to the tomcat JVM with ( in the JAVA_OPTS)

-XX:MaxPermSize=256m

or whatever size you want.

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

Solution is to increase PermGen heap size in catalina.bat of tomcat server; this can give you some breathing space but eventually this will also return in java.lang.OutOfMemoryError: PermGen space after some time.

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.

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.

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 :

Solving run-time OutOfMemoryError

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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