UnixServerAdmin

Server Administration & Management

java.lang.OutOfMemoryError: PermGen space

While accessing the .jsp pages or restarting tomcat on the server you face the error “java.lang.OutOfMemoryError: PermGen space”.  The error occurs due to the memry outage for  the tomcat service on the server. By default the tomcat uses 128 MB of memroy. You can increase the memory with the steps below and get rid off the errors.

HTTP Status 500 –
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.OutOfMemoryError: PermGen space
note The full stack trace of the root cause is available in the Apache Tomcat/
Apache Tomcat

1) Edit file /usr/local/jakarta/tomcat/bin/catalina.sh

# vi /usr/local/jakarta/tomcat/bin/catalina.sh

2) Add following line into the catalina.sh file.

JAVA_OPTS=”-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

Which will look like

=======================================================================
# JSSE_HOME (Optional) May point at your Java Secure Sockets Extension
# (JSSE) installation, whose JAR files will be added to the
# system class path used to start Tomcat.
#
# CATALINA_PID (Optional) Path of the file which should contains the pid
# of catalina startup java process, when start (fork) is used
#
# $Id: catalina.sh 609438 2008-01-06 22:14:28Z markt $
# —————————————————————————–

JAVA_OPTS=”-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC”

# OS specific support. $var _must_ be set to either true or false.
cygwin=false
os400=false
darwin=false
=======================================================================

3) Save and exit

4) Restart Tomcat

Advertisements

October 30, 2011 Posted by | Tomcat | | Leave a comment