MaxPermSize for Tomcat as a Windows Service

January 12, 2011

I wanted to set the MaxPermSize flag for a Tomcat instance, but one that was running as a windows service using service.bat.

At the bottom of service.bat is the code that adds parameters to the JVM call:

"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions="-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\common\endorsed" --StartMode jvm --StopMode jvm --Startup auto
rem More extra parameters
set PR_STDOUTPUT=%CATALINA_HOME%\logs\stdout.log
set PR_STDERROR=%CATALINA_HOME%\logs\stderr.log
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions="-Djava.io.tmpdir=%CATALINA_BASE%\temp"  --JvmMs 128 --JvmMx 1024

--JvmOptions initialises the parameter list, ++JvmOptions adds additional parameters

I tried all combinations of adding MaxPermSize=128m to this to get it to work, and it wouldn't. I finally solved it by adding another line.

As ++JvmOptions applies additional parameters to the JVM we can add another line in the file with:

"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions="-XX:MaxPermSize=128m"

to add the additional PermGen settings.