2
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.

Roman C
  • 49,761
  • 33
  • 66
  • 176
murthy
  • 21
  • 2
  • When deploying or when _re_deploying / reloading the context? Have you tried increasing the PermGen Space? – Michael Dec 31 '14 at 10:11
  • Netbeans is notorious for memory leaks on redeployment – Edward J Beckett Dec 31 '14 at 10:22
  • Redeploying multiple times increases the PERmanent GENeration allocated size. You just need to restart the Application Server after a certain number of deploys. http://stackoverflow.com/questions/318942/what-does-permgen-actually-stand-for – Andrea Ligios Dec 31 '14 at 11:08

3 Answers3

0

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/

yUdoDis
  • 1,098
  • 6
  • 15
0

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.

Abhishek
  • 878
  • 12
  • 28
0

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.

Jorge Valdés
  • 629
  • 9
  • 16