Tomcat configuration

I’m having some memory issues on a new box where I’m moving about 120 websites to, from CF10 environment. Every couple of hours “There is insufficient memory for the Java Runtime Environment to continue.” is logged. I have the initial memory set to 4192 MB and Max at 5120 MB. The server has 15.5 GB of memory overall.

I read on another topic that they solved this issue by increasing the number of threads. My question is which connector do you add the ‘maxthreads’ option to? In my server.xml file I see 2 connectors, one for http/1.1 and AJP/1.3.

Don’t forget to tell us about your stack!

OS: Windows Server 2012 R2 (6.3) 64bit
Java Version: 11.0.7 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.35
Lucee Version: Lucee


I will try that suggestion, however, I would like to know which connector you add parameters to.

Depending on the configuration, unless the 120 sites share the same webroot, generally speaking Lucee will run each site as a separate context which requires more memory than ACF.

Lucee 6 will support a single context like ACF, I seriously doubt changing threads config will help you here, you are simply running out of memory required for all the contexts.

5.3.8 does at times use less memory than 5.3.7

1 Like

I would up the memory configuration to be a static 8 GB and gc to be a bit more aggressive.

These are sample values, as you may need to tweak this to your own application needs, but its what I would start out with.

-Xms8g -Xmx8g -XX:ParallelGCThreads=2 -XX:MaxGCPauseMillis=150 (default is 200) -XX:GCTimeRatio=95 (this meens your application will spend 5 percent of the time in the garbage collector, default is 99 which is 1 percent)

1 Like

My current configuration is -Xms4g -Xmx4g but I feel like those are being ignored. Screenshot 2021-05-27 082510

Why is this happening?

The version of tomcat for lucee is modified from the default version, so you have to just adapt a little.

in line 201 & 202 of LuceeRoot\tomcat\bin\service.bat

change (your values maybe different)
if “%JvmMs%” == “” set JvmMs=256
if “%JvmMx%” == “” set JvmMx=512

if “%JvmMs%” == “” set JvmMs=8192
if “%JvmMx%” == “” set JvmMx=8192

If lucee at 5.7GB is using 96 percent of the memory,are you sure your server has access to all 15.5 gb of memory?

Lucee wouldn’t start with those options.

isn’t g meant to be G?

Yes, the rest of memory is being used by IIS workers, I’m in the process of moving each site into one application pool to free up overall system memory.

Windows ignores case, *NIX it matters 99.999 percent of the time :slight_smile:

java args aren’t windows :slight_smile:

1 Like

You have to set your JAVA_Opts before executing the application startup (Tomcat)

You would set JAVA_OPTS in catalina.bat

1 Like

In case you are running Lucee/Tomcat as a service in Windows, no server.bat or setenv.bat will be used. To configure those variables you need to add the System Properties in the JAVA tab of Tomcats GUI service editor. You can open it by running the following command in a cmd terminal with admin priveleges:

path-to-lucee-installation\tomcat\bin\tomcat9w.exe //ES//NameOfYourTomcatService

That will probably be for you:

C:\lucee\tomcat\bin\tomcat9w.exe //ES//lucee

You can look at further informations here:

I’m not sure what I’m doing wrong. Even copy/paste these params in the Java Options tab causes the service not to start:

-server -Xms6G -Xmx6G -XX:PermSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70

recommended turning options from Oracle

Is that guide for java 11?

in C:\lucee\tomcat\bin\ (OR WHERE EVER YOU INSTALLED LUCEE)

edit the file catalina.bat in notepad.exe
right under



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

Save the file

Now create a new file, call it setenv.bat
in the same directory

In that file add only the following line

set JAVA_OPTS="-Xms6G -Xmx6G -XX:PermSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"

Save the file
restart your lucee service

@terry, that won’t work if you are running Tomcat as service in Windows. Those files are not caught by the tomcat service :confused:

you have to re-register the service.

cmd (as administrator)
go to catalinahome\bin
run service.bat remove
run service.bat install

if done correctly, Service.bat calls on line 230
--JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-D%ENDORSED_PROP%=%CATALINA_HOME%\endorsed;\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\;%JvmArgs%"

CATALINA_Home is set by catalina.bat (or should be) which in question we then are calling to set the new args in a upgrade proof bat

line 233 of service.bat need to be removed

Confirmed, odd behavior.

I added this to line 201 of service.bat

f "%JvmMs%" == "" set -Xms6G -Xmx6G -XX:PermSize=512m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"

Its called both in catalinaHOMe and JVM
neither is being passed by the exe wrapper.

River_bender, how have things gone since you brought this up? If you’re still having problems, I have some thoughts from looking across the whole thread of replies.

First, I will say that the error you report is an indication not that Lucee (or Tomcat or the JVM) is “out of memory” but rather that your box was, at the time, so that in fact it could not give Lucee/Tomcat/the JVM the memory is had been told it could have (via the xmx). And indeed you indicated later that IIS workers were using up most of the OS memory.

Then as for your sense that your settings of XMX were being ignored, it may have to do with where you were setting those. You don’t indicate that at first, same for when you said that with a set of jvm args Terry offered “lucee wouldn’t start”. Where were you putting those?

Then later Andreas proposed you put them in the java options tab of the tomcat9w.exe. You said you put them there and the service would not start. To be clear, those args need to each be on their own line (in that “java options” tab, as opposed to about anywhere else). Also, in that UI, note that the min and max heap are to be set in a separate field offered, rather than as normal java args.

Finally, in case anyone finds this thread in the future, and they find that that tomcat9w.exe fails to open (reporting the specified service does not exist as an installed service. unable to open the service ‘tomcat9’), look for a luceew.exe instead and try that.

Let us know if any of this gets you going, River_bender, or if perhaps you were already set (in which case I leave this as info for future readers).

1 Like