Wednesday, September 3, 2014

How do I properly set the permgen size?

Two ways to solve perm gen (out of memory ) problem.

1.

 You have to change the values in the CATALINA_OPTS option defined in the Tomcat Catalina start file. To increase the

PermGen memory change the value of the MaxPermSize variable, otherwise change the value of the Xmx variable.

Linux :
Open Catalina.sh file placed in the "bin" directory. You have to apply the changes to this line

CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"

Windows:

Open the "Catalina.bat" file placed in the "bin" directory

set CATALINA_OPTS=-server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m


2.
You can use any text editor to create the file. Make sure that it is syntactically a valid Window batch script. Most of

the time, you would just set environment variables in this file.

For example:

set JAVA_HOME=C:\path\to\java\home
set CATALINA_OPTS=-Xmx2G -Xss256k

As a note, you only want to use the setenv.bat file if you are running Tomcat from the console (something that is done rarely). In most cases, you'll be running as a Windows Service. If you are running as a Windows Service then you don't want to use setenv.bat. Instead, you'll want to use the Tomcat GUI application to make configuration changes.

NOTE:
but it must be said that if you have a fundamental memory leak in your app, it probably doesn't matter how large you set the heap - you'll still run out off memory

0 comments:

Post a Comment