It’s quite common to run In memory problems when running some big Java EE application on a Tomcat server.
I have recently installed Alfresco 3.4.x and I was facing the following java.lang.OutOfMemoryError: PermGen space error .
java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
It’s usually happens when the Tomcat start and stop few times. You can fine tune it with some minor changes in the Tomcat configuration setting. By default, Tomcat assigned very little memory for the running process, you should increase the memory by make change in catalina.sh or catalina.bat file
.
How to fix it?
- Stop the Tomcat Server.
- Find where is Cataline.bat located. We need to make some changes in “catalina.bat” file.
Catalina.bat file is located at \tomcat\bin\catalina.bat
- Assign following line to JAVA_OPTS variable and add it into catalina.bat file.set JAVA_OPTS=-server -Xms512M -Xmx768M -XX:MaxPermSize=256m
Partial Example of catalina.bat file
….
if not "%LOGGING_CONFIG%" == "" goto noJuliConfig
set LOGGING_CONFIG=-Dnop
if not exist "%CATALINA_BASE%\conf\logging.properties" goto noJuliConfig
set LOGGING_CONFIG=-Djava.util.logging.config.file="%CATALINA_BASE%\conf\logging.properties"
:noJuliConfig
set JAVA_OPTS=-server -Xms512M -Xmx768M -XX:MaxPermSize=256m
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%
if not "%LOGGING_MANAGER%" == "" goto noJuliManager
set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
:noJuliManager
set JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%
….
- Done. Restart the Tomcat Server.
No comments:
Post a Comment