Methods that are not feasible
Initially I changed directly catalina.sh
, adding JAVA_OPTS
the variable to the
-server-Xms1G-Xmx1G-XX:+UserG1GC
It didn't seem to be a problem at first, but when the server ran for a few days, it found that execution shutdown.sh
could not shut down Tomcat with the following error message:
# [Email protected]:~/projects/taolijie# cat Hs_err_pid5519.log# There is insufficient memory for the Java Runtime environment to continue.# Native memory allocation (MMAP) failed to map 1073741824 bytes for committing reserved memory.# Possible reasons:# The system is out of physical RAM or swap space# in + bit mode, the process size limit is hit# Possible Solutions:# Reduce Memory load on the system# Increase physical memory or swap space# Check If swap backing store is full# Use a bit of Java on a A-bit OS# Decrease Java Heap Size (-XMX/-XMS)# Decrease number of Java threads# Decrease Java Thread stack sizes (-XSS)# Set Larger code cache with-xx:reservedcodecachesize=# This output file could be truncated or incomplete.## Out of Memory Error (os_linux.cpp:2673), pid=5519, tid=3061726064## JRE version: (8.0_45-B14) (build)# Java Vm:java HotSpot (TM) Server VM (25.45-b02 mixed mode linux-x86)# Failed to write core dump. Core dumps has been disabled. To enable core dumping, try "ulimit-c unlimited" before starting Java again#
Shut down a tomcat to request 1G of memory, then the server left 200M of memory, so out of a memory. View shutdown.sh
, found that it was actually called catalina.sh
, just passed in a stop
parameter. and catalina.sh
it was executed.
org.apache.catalina.startup.Bootstrap stop
To send the shutdown message to Tomcat. Since we set up the JAVA_OPTS
heap using 1G above, the JVM will request 1G more memory from the system when executing the class, resulting in a direct result out of the memories.
Possible methods
On catalina.sh
the second line, add:
CATALINA_OPTS="$CATALINA_OPTS -server -Xms1G -Xmx1G -XX:+UseG1GC"
These VM parameters will be applied only to Catalina and not to all Tomcat processes.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The tomcat VM parameter modification under Linux