Sunday, November 19, 2017

Difference between setting Heap memory in terms of jvm and Tomcat

Memory settings apply to the JVM, not Tomcat
You can create a separate file %CATALINA_HOME%\bin\setenv.bat or $CATALINA_HOME/bin/setenv.shand put your environment variables there.
so I'd like to set the JAVA_OPTS variable instead:
set JAVA_OPTS=-Xmx512m

For Xmx:

Specifies the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. So, in simple words, you are saying Java to use Maximum of 1024 MB from available memory.
NOTE: there is NO SPACE between -Xmx and 1024m

Resource Link:

  1. How to Change JVM Heap Setting (-Xms -Xmx) of Tomcat – Configure setenv.sh file – Run catalina.sh
  2. How to Increase Apache Tomcat HeapSize (JVM Heap) in Eclipse IDE (integrated development environment) to Avoid OutOfMemory

UPDATE1: Setting Up Multiple Tomcat Instances

Multiple Tomcat instances are possible to create with the use of the CATALINA_BASE environment variable. Each instance uses a common binary distribution but uses its own conf, webapps, temp, logs and work directories. Each instance also has its own JVM and, thereby, its own memory pool. If you have defined the maximum memory to be 512MB via JAVA_OPTS, each instance will attempt to allocate a maximum of 512MB.
For more details, you can go through this tutorial: Connecting Apache's Web Server to Multiple Instances of Tomcat

Resource Link:

  1. 5 Scenarios and Best Practices for Running Multiple Instances of Tomcat or tc Server
Resource Link: https://stackoverflow.com/a/37966159/2293534

No comments:

Post a Comment