2

I keep reading that I should set the JVM parameters for Catalina in my Catalina.sh file. I am running Tomcat 8 as a Windows service. There is no Catalina.sh file. I tried adding JVM optimizations to System environment variable CATALINA_OPTS but I don't see it having any effect. The Tomcat log file indicates the same default Xms and Xmx (and other) parameters. Or are these the Tomcat parameters (for Tomcat itself) and not the parameters for my geoserver application?

Here is what I put in the global Environment strings in Windows:

CATALINA_OPTS=-server -Xmx512m -Xms48m XX:SoftRefLRUPolicyMSPerMB=36000 -XX:MaxPermSize=128m -XX+UseParallelGC

And here is what my log says:

20-Jan-2016 09:49:48.240 INFO [Thread-9] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
20-Jan-2016 09:49:48.334 INFO [Thread-9] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.30
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Dec 1 2015 22:30:46 UTC
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.30.0
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows Server 2012
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.2
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          x86
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files (x86)\Java\jre7
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.7.0_79-b15
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0
20-Jan-2016 09:51:23.423 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\endorsed
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\temp
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\conf\logging.properties
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: exit
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms128m
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx256m
20-Jan-2016 09:51:23.454 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:/PROGRA~2/GDAL-Native-1.9.2;c:\Program Files\ANT\bin;C:\Program Files (x86)\Java\jre7\bin ;;.
20-Jan-2016 09:51:26.766 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Jan-2016 09:51:27.300 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jan-2016 09:51:27.313 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
20-Jan-2016 09:51:27.313 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Jan-2016 09:51:27.313 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 13126 ms
20-Jan-2016 09:51:27.767 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
20-Jan-2016 09:51:27.767 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.30
20-Jan-2016 09:51:28.094 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\geoserver.war
20-Jan-2016 09:52:06.329 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
20-Jan-2016 09:52:13.235 INFO [localhost-startStop-1] it.geosolutions.imageio.gdalframework.GDALUtilities.loadGDAL GDAL Native Library loaded (version: 1.9.2)
20-Jan-2016 09:52:14.438 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'XStreamPersisterInitializer', but ApplicationContext is unset.
20-Jan-2016 09:52:14.438 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionFilter', but ApplicationContext is unset.
20-Jan-2016 09:52:14.454 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionProvider', but ApplicationContext is unset.
20-Jan-2016 09:52:14.469 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionFilter', but ApplicationContext is unset.
20-Jan-2016 09:52:17.376 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'GeoServerSecurityProvider', but ApplicationContext is unset.
20-Jan-2016 09:52:17.376 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionFilter', but ApplicationContext is unset.
20-Jan-2016 09:52:17.376 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionProvider', but ApplicationContext is unset.
20-Jan-2016 09:52:17.376 WARNING [localhost-startStop-1] org.geoserver.platform.GeoServerExtensions.checkContext Extension lookup 'ExtensionFilter', but ApplicationContext is unset.
20-Jan-2016 09:52:55.797 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\geoserver.war has finished in 87,703 ms
20-Jan-2016 09:52:55.813 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\docs
20-Jan-2016 09:52:55.907 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\docs has finished in 94 ms
20-Jan-2016 09:52:55.907 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\host-manager
20-Jan-2016 09:52:56.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\host-manager has finished in 94 ms
20-Jan-2016 09:52:56.001 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\manager
20-Jan-2016 09:52:56.063 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\manager has finished in 62 ms
20-Jan-2016 09:52:56.063 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\ROOT
20-Jan-2016 09:52:56.126 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files (x86)\Apache Software Foundation\Tomcat 8.0\webapps\ROOT has finished in 63 ms
20-Jan-2016 09:52:56.157 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
20-Jan-2016 09:52:56.157 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
20-Jan-2016 09:52:56.173 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 88852 ms

If it matters I'm using JRE 7 32bit.

And Geoserver itself reports:

Locks   0   
Free locks
Connections 27  
Memory Usage    134 MB  
Free memory
JVM Version Oracle Corporation: 1.7.0_79 (Java HotSpot(TM) Client VM)   
Available Fonts GeoServer can access 301 different fonts. 
Native JAI  true    
Native JAI ImageIO  true    
JAI Maximum Memory  123 MB  
JAI Memory Usage    0 KB    
Free memory
JAI Memory Threshold    75.0    
Number of JAI Tile Threads  7   
JAI Tile Thread Priority    5   
ThreadPoolExecutor Core Pool Size   5   
ThreadPoolExecutor Max Pool Size    10  
ThreadPoolExecutor Keep Alive Time (ms) 30000   
Update Sequence 940

Any advice on how/where to ensure the settings recommended in the Geoserver documentation are used?

I'm trying to follow recommendations on this page

http://docs.geoserver.org/stable/en/user/production/container.html

  • try looking for catalina.bat (.sh is a linux bat file) – Ian Turton Jan 20 '16 at 16:22
  • I've tried, as documented, to create a setenv.bat file in the bin folder. Posts said not to change catalina.bat directly. setenv.bat has the following: (single line): set CATALINA_OPTS=-server -Xms512m -Xmx1536m -XX:PermSize=128m -XX:MaxPermSize=128m But it has NO effect, I still get out of memory errors, while Geoserver status says it is using just 249m. – Brian B Jan 26 '16 at 2:34
5

Well, I gleaned this information from many different posts. There are several "answers" out there, but I only found one that actually worked.

First of all, if you are running Tomcat 8.0 as a service in the Windows OS, those BAT files (catalina.bat, setenv.bat if you created one) do not seem to be relevant at all. There are many who say "edit catalina.bat" or "add such and such to your setenv.bat file in the Tomcat bin folder", or "add CATALINA_OPTS environment variable with JVM parameters you want to use". None of these things have any effect on the Geoserver web app running in Tomcat 8, at least when it is running as a Windows service.

So, how do you tune/configure your JVM when running Tomcat 8.0 as a service? Assuming you "Installed" Tomcat 8.0 using the Windows Installer, go to your program menu and find the "Configure Tomcat" program. It brings up a properties window that looks as seen below. Use the Java tab. There is a field called "Java Options". Put all but the Xmx and Xms settings, as there are special fields below the Java Options field for these two values. So I added the following options:

-XX:SoftRefLRUPolicyMSPerMB=36000
-XX:MaxPermSize=128m
-XX:+UseParallelGC

These are exactly as recommended values from the Geoserver documentation regarding Container Considerations (see here: http://docs.geoserver.org/stable/en/user/production/container.html)

I'm currently running 32bit Tomcat 8.0 and 32bit JRE7 because the ImageIO native features documented by Geoserver are only available in 32bit. So I'm limited in how much of my machine's 8GB of RAM I can give to the jvm running Geoserver.

I'm not sure I'm actually using them (the native ImageIO dlls), though, and will consider upgrading everything to 64bit, so I can give the JVM even more memory. But because I am using 32bit, I found the following "Initial memory pool" and "Maximum memory pool" settings worked, and are working well:

Initial memory pool:  512m
Maximum memory pool:  1536m

It seems you must be careful what values you put in these fields. I'm using multiples of 512m. When I tried initial memory pool of 768m, Tomcat service would not start. If anyone can help clarify what the valid values for these fields are, feel free to add a comment to this answer. It was trial and error, and very frustrating to change an initial memory field to something that seemed reasonable, and this would cause the service to simply fail to start entirely. Found this in a log file: Error 4. Thanks for that explanation...

So here is what the config should look like. All the Java Options below the ones I added are exactly what were there already from the Tomcat installation: enter image description here

Now when I logon to Geoserver's admin and select Server Status, I can see the following: JAI Maximum Memory 682 MB. JAI max memory is set to 50%, so this means there is 1364m available. I'm assuming the rest is Permgen or stack space, or some other use of memory. The default Tomcat settings provide a lot less than that (initial memory of 128m and max of 256m).

So far, it is running very well, all of the out of memory (Permgen) errors and other out of memory errors I've been trying to resolve no longer occur. The geoserver webapp also loads 30-40% faster than it did when it had a lot less memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.