0

What settings must I change to allow Tomcat 8.5 more memory, in the range of 4 gigs, on the Oracle JDK for Java 8?

This has been asked before here. But that was marked (incorrectly) as a duplicate of this. The context for both Questions and their Answers was an older generation of Tomcat (version 7, versus contemporary 8.5), and an older generation of Java (Java 6 & Java 7 versus contemporary Java 8). So all the discussion was around PermGen which no longer exists in modern Java.

➠ What is the modern settings for giving Tomcat 8.5.x more memory on Java 8 Update 151 using the Java implementation provided by Oracle for macOS etc.?

If not specified, what is the minimum & maximum memory used by Tomcat?


Scraping together some info from various sources such as this RUNNING.txt document, I created a setenv.sh file in the Tomcat bin folder, with this line of text:

CATALINA_OPTS="-Xms4096m -Xmx4096m"

I expected that to immediately take 4 gigs of memory, but alas, no. On Mac OS X, I see the virtual memory for the java process at 1.87 GB and the real memory at 1.39 GB.

So I am not sure what controls the min/max memory usage of Tomcat 8.5.23.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • Using the `-Xmx4196m` flag does not help? – Naman Oct 23 '17 at 19:10
  • @nullpointer See edit, section at bottom explaining that using that X flag may not have done the job. – Basil Bourque Oct 23 '17 at 19:54
  • I am wondering if I should have posted this Question on [Server Fault Stack Exchange](https://serverfault.com) rather than here on Stack Overflow. – Basil Bourque Oct 23 '17 at 19:55
  • The memory will be raised, as soon as the Jvm is restarted, provided that the setens.sh is run at all. Make sure this file is run at startup (check rights also) and use jvisualvm or jmc (to be found in the `jdk/bin` directory) to see the amount of max memory. – Stefan Oct 24 '17 at 06:16
  • @Stefan How does one verify that the "setenv.sh" file ran? – Basil Bourque Oct 24 '17 at 06:21
  • 1
    Maybe _export_ the variable, e.g. `export CATALINA_OPTS="-Xms4096m -Xmx4096m"` – Bragolgirith Oct 24 '17 at 16:26

1 Answers1

0

In your setenv.sh, you need to export, as shown in the comment from @vtosh:
export CATALINA_OPTS="-Xms4096m -Xmx4096m"