pedram ezzati pedram ezzati - 12 days ago 6
Java Question

Tomcat memory not increasing

i have time create setenv.sh as below

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


but when tomcat start it , on one core cpu it is started by 500MB
and in 2 core cup it start with 1GB

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

when i want to start the tomcat id run it by below command

./catalina.sh start


in CATALINA.SH below code is already exits which 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

Answer

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.

Comments