Search code examples
javatomcatmemorywebservertomcat8

Why Tomcat Memory is not Increasing


The server which Application is installed on it has 1G Memory . But when tomcat start it only start by 500MB

I have create setenv.sh as below

export CATALINA_OPTS="$CATALINA_OPTS -Xms2024m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx3024m"

I need to know why it is not staring with 2GB

When i want to start the tomcat use below command

./catalina.sh start

In CATALINA.SH below code is already exits , which will calls the setenv.sh

if [ -r "$CATALINA_BASE/bin/setenv.sh" ]; then
  . "$CATALINA_BASE/bin/setenv.sh"
elif [ -r "$CATALINA_HOME/bin/setenv.sh" ]; then
  . "$CATALINA_HOME/bin/setenv.sh"
fi

I have check tomcat log , it is mentioned that it is start with 2024m but It is still not using the 2G Ram

INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms2024m
INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx3024m
INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/share/tomcat

Solution

  • Is tomcat starting in setenv.sh? Environment variables are inherited into child processes and will not affect the parent, so the following will not work:

    $ ./setenvh.sh
    $ ./start-tomcat.sh
    

    Because the shell is the parent process, the variable gets set in a child process (setenv.sh) and then "forgotten" when that script exits.

    The following will work:

    $ . ./setenv.sh
    $ ./start-tomcat.sh
    

    Because the . executes setenv.sh in the current shell and modifies your variables before starting tomcat in a child process.