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?
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?
In your environment. Our you could create a wrapper script that sets JAVA_OPTS then calls the catalina script.
Like others have already suggested you need to use
JAVA_OPTS
set to something like:JAVA_OPTS="-XX:MaxPermSize=98m"
. This, alone, will probably solve the issues, but if you are redeploying a lot of times and your war/jar is huge you will hit this memory limit too.For this last scenario, something normal on a test/devel machines, I recommend using:
-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
This options will enable the unloading of the unused classes.
Look here more details, especially the comments.
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 orsetenv.sh
for Linux with entry as below:Windows:
Linux:
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:
Linux:
This will take care the rest.
This happened because you redeployed several times. You can increase your perm gen space, but it'll only delay the inevitable error.
You'll just have to restart your server. I'm not aware of a workaround.
The proper place is to create a new file in the Tomcat /bin directory alongside catalina.bat, named
setenv.bat
and place aset JAVA_OPTS=...
there.On *nix system it'd be
setenv.sh
catalina.bat/catalina.sh takes care of running setenv.bat/setenv.sh if it exists. This is noted in the section 3.4 here