I am working in a Windows Environment, and I am getting this error every time I am working with tomcat-
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@4ae53a99
2012-04-30 17:30:37.719 INFO net.spy.memcached.MemcachedConnection: Reconnecting due to failure to connect to {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connection refused: no further information
Apr 30, 2012 5:30:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.OutOfMemoryError: PermGen space
Exception in thread "Memcached IO over {MemcachedConnection to localhost/127.0.0.1:11211}" java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:38 PM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:41 PM org.apache.catalina.connector.CoyoteAdapter service
SEVERE: An exception or error occurred in the container during the request processing
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:43 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/error.action]
java.lang.OutOfMemoryError: PermGen space
Apr 30, 2012 5:30:42 PM org.apache.catalina.core.StandardHostValve custom
SEVERE: Exception Processing ErrorPage[exceptionType=java.lang.Throwable, location=/error.action]
java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
I tried adding JAVA_OPTS with the value as -Xms1024m -Xmx1024m
in System Variables, but I am stillgetting the same error (java.lang.OutOfMemoryError: PermGen space) again and again.
Any help will be appreciated. I have also read other posts on Stack Overflow also but it didn't work out.
I'm running tomcat7 on CentOS 6.6. I tried creating a new /usr/share/tomcat/bin/setenv.sh file and setting both JAVA_OPTS
and CATALINA_OPTS
. But tomcat wouldn't pick up the values on restart. When I put the following line into /etc/tomcat/tomcat.conf:
CATALINA_OPTS="-Xms128m -Xmx1024m -XX:MaxPermSize=1024m"
tomcat did pick up the new environment variable. I verified this by running
ps aux | grep tomcat
and seeing the new settings in the output. This took a long time to diagnose and I didn't see anyone else suggesting this, so I thought I'd throw it out to the internet community.
I tried the same on Intellij Ideav11.
It was not picking up the settings after checking the process using grep. In case it does not, give the mem settings for JAVA_OPTS in catalina.sh instead.
On server window Double click on tomcat, It will open the tomcat's Overview window .
In the Overview window you will find Open launch configuration under General information and click on Open launch configuration.
@AndreSmiley 's code of line worked for me.
only modification required is.
-XX:MaxPermSize=256m
"m" means MB.
Actually my application is kinda huge so i was advised to make it 1024m for performance.
You have to allocate more space to the PermGenSpace of the tomcat JVM.
This can be done with the JVM argument : -XX:MaxPermSize=128m
By default, the PermGen space is 64M (and it contains all compiled classes, so if you have a lot of jar (classes) in your classpath, you may indeed fill this space).
On a side note, you can monitor the size of the PermGen space with JVisualVM and you can even inspect its content with YourKit Java Profiler
In Tomcat 7.0 Windows Service Installer Version.There is not catalina.bat in /bin . So you need open Tomcat7w.exe in /bin and add blow JVM argument
-XX:PermSize=256m -XX:MaxPermSize=512m
on Java Option in Java Tab, like this. You also add other options.
Another, if you use IntellijIDEA you need add JVM argument in Server Configurations,like this.
To complement Michael's answer, and according to this answer, a safe way to deal with the problem is to use the following arguments:
-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+UseConcMarkSweepGC
This one worked for me, in startup.bat
the following line needs to be added if it doesn't exist set JAVA_OPTS
with the value -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256
. The full line:
set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256
If tomcat is running as Windows Service neither CATALINA_OPTS nor JAVA_OPTS seems to have any effect.
You need to set it in Java options in GUI.
The below link explains it well
http://www.12robots.com/index.cfm/2010/10/8/Giving-more-memory-to-the-Tomcat-Service-in-Windows
Killing the tomcat process(forcefully, kill -9 for Linux) and starting it again solves the issue. My guess is, the tomcat instance doesn't get killed properly using shutdown.bat. So, we need to forcefully kill the process and start again.
Source: Stackoverflow.com