2

I have Apache Tomcat 7.0.27 installed on a 64 bit CentOS server with 37G of physical memory available. For the web application I'm running in Tomcat I need a large amount of memory available so I've set up my Tomcat setenv.sh similar to below:

export JAVA_OPTS="
    -Xms30g 
    -Xmx30g 

    -XX:PermSize=256m 
    -XX:MaxPermSize=256m

    -XX:NewSize=6g 
    -XX:MaxNewSize=6g
    -XX:SurvivorRatio=8

    -XX:+DisableExplicitGC
    -XX:+UseConcMarkSweepGC 
    -XX:+UseParNewGC
    -XX:+UseCMSInitiatingOccupancyOnly
    -XX:CMSInitiatingOccupancyFraction=80"

My Java version is:

java version "1.6.0_41"
Java(TM) SE Runtime Environment (build 1.6.0_41-b02)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)

The application starts and runs fine when I run {tomcat_home}/bin/startup.sh but occasionally when I shutdown with {tomcat_home}/bin/shutdown.sh I get the following message:

Error occurred during initialization of VM
Could not reserve enough space for object heap

Why is this happening?

Tom
  • 3,006
  • 6
  • 33
  • 54

1 Answers1

1

The shutdown script tries to do an orderly shutdown by running a small Java program that connects to Tomcat's shutdown port (8009?) and sends a message.

That program runs in its own JVM, and if your system is low on memory it might not be able to start up that JVM to send the shutdown command to the running Tomcat.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
  • The 'top' command shows that there is still 3.5G of free space on the machine. I would expect this to be enough to run that small shutdown program. Does that program use the same java opts that are set in {tomcat_home}/bin/setenv.sh perhaps? – Tom Mar 17 '16 at 19:54
  • 1
    This answer http://stackoverflow.com/questions/11222365/catalina-opts-vs-java-opts-what-is-the-difference shows that I should be specifying my heap size in the CATALINA_OPTS variable in setnenv.sh instead of in JAVA_OPTS. Anything in JAVA_OPTS is used for the shutdown pram that this answer refers to. So essentially I was trying to allocate 30 more gigs just to shutdown Tomcat. – Tom Mar 17 '16 at 20:25