> From: James H. H. Lampert [mailto:jam...@touchtonecorp.com] 
> Subject: Problem with CATALINA_OPTS in setenv.sh

> 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

> We're running on a Google Compute instance, with 1 CPU and 4G of memory, 

> 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?

A bit of research shows that +AlwaysPreTouch seems like a really, really bad
idea for anything but small, bare-metal, dedicated systems, and especially
useless on a VM:

"With the -XX:+AlwaysPreTouch option the JVM touches every single byte of
the max heap size with a '0', resulting in the memory being allocated in the
physical memory in addition to being reserved in the internal data structure
(virtual memory). Pretouching is single threaded, so it is expected behavior
that it causes JVM startup to be delayed. The trade off is that it will
reduce page access time later, as the pages will already be loaded into
memory."

The fact that Tomcat is crashing during the pre-touch would indicate that
you can't actually use a 2 GiB heap on a supposed 4 GiB VM - something other
than the heap is eating up a lot of space.  You should probably remove the
option and reduce the heap size.

  - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to