Problem with CATALINA_OPTS in setenv.sh, in Tomcat running on a GCE instance

213 views
Skip to first unread message

James Lampert

unread,
Aug 2, 2018, 1:40:28 PM8/2/18
to gce-discussion
I've been experimenting with some CATALINA_OPTS changes, as recommended by our webapp developer, and one of them is causing Tomcat to "crash on takeoff" with stacktraces like this:
30-Jul-2018 22:58:00.708 SEVERE [main] org.apache.coyote.AbstractProtocol.init
    Failed to initialize end point associated with ProtocolHandler ["http-nio-80"]
 java.net.SocketException: Cannot allocate memory
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:970)
. . .

We're running on an instance with 1 CPU and 4G of memory, running the Debian version of Tomcat 8.5.14, with Manager showing a JVM is "1.8.0_171-8u171-b11-1~deb9u1-b11."

The "baseline" CATALINA_OPTS, that we'd been using, is
-Xms512m -Xmx2524m -XX:MaxPermSize=256m
-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled

(And yes, I know that MaxPermSize is obsolete and deprecated in Java 8.)

What the webapp developer asked for was (after I'd vetted his request against the Java 8 docs)
-Xms2048m -Xmx2048m -XX:+ScavengeBeforeFullGC -XX:+AlwaysPreTouch
-XX:+CMSScavengeBeforeRemark -XX:+CMSClassUnloadingEnabled
-XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled

which produced the crash-on-takeoff, and I was able to narrow it down to specifically the "-XX:+AlwaysPreTouch" that was doing it.

Anybody have any insights into why that parameter would cause Tomcat to crash on takeoff? 

James Lampert

unread,
Aug 2, 2018, 7:06:49 PM8/2/18
to gce-discussion
Not knowing whether it was Tomcat-specific or Google-specific, I posted the same question (at about the same time) on the Tomcat Users list-server.

The general consensus there was that in a virtual machine environment, the "-XX:+AlwaysPreTouch" was meaningless at best, and destructive at worst.

Mehdi (Cloud Platform Support)

unread,
Aug 9, 2018, 1:25:07 PM8/9/18
to gce-discussion
Actually, Google groups are for general discussions of the products. Custom configuration issues questions are more suitable for Stackoverflow or Serverfault where the community can assist you with those kind of issue, like in your case that you reached out to Tomcat Users. 
Reply all
Reply to author
Forward
0 new messages