Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appropriate place in catalina.bat to set JAVA_OPTS

Tags:

java

tomcat

I got the below error

"java.lang.OutOfMemoryError: PermGen space"

In my catalina.bat file, where is the appropriate place for enter set JAVA_OPTS parameter? Bottom of the file or any other place?

like image 363
Priyan at Dialog Avatar asked Oct 31 '12 18:10

Priyan at Dialog


Video Answer


1 Answers

Please read this: OutOfMemory Error and make sure your application doesn't have memory leak and excessive memory usage.

To change the settings, create a file named setenv.bat for windows or setenv.sh for Linux with entry as below:

Windows:

set JAVA_OPTS="-Xms256m -Xmx512m"

Linux:

export JAVA_OPTS="-Xms256m -Xmx512m"

Simply put this(setenv.bat/setenv.sh) file in %CATALINA_HOME%\bin\ folder. Your command file (catalina.bat/catalina.sh) already has a statement as below:

Windows:

  if exist "%CATALINA_HOME%\bin\setenv.bat" call "%CATALINA_HOME%\bin\setenv.bat"

Linux:

  if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
     . "$CATALINA_BASE/bin/setenv.sh"
  elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
     . "$CATALINA_HOME/bin/setenv.sh"
  fi

This will take care the rest.

like image 64
Yogendra Singh Avatar answered Oct 17 '22 17:10

Yogendra Singh