Tom
Tom

Reputation: 3166

Tomcat shutdown fails with memory error

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?

Upvotes: 2

Views: 1463

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

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.

Upvotes: 1

Related Questions