Tomcat VM parameter changes under Linux

Source: Internet
Author: User

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 the runtime shutdown.sh could not shut down Tomcat, such as the following:

# [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 , and found that it was actually called catalina.sh , just passed in a stop number of parameters. And catalina.sh it's running.

org.apache.catalina.startup.Bootstrap stop

To send the shutdown message to Tomcat. Because we set up a JAVA_OPTS heap that uses 1G above. Therefore, when running this class, the JVM will request more than 1G of memory to the system, directly resulting in the out of memories.

Possible methods

On catalina.sh the second line, add:

CATALINA_OPTS="$CATALINA_OPTS -server -Xms1G -Xmx1G -XX:+UseG1GC"

These VM parameters will only be applied to Catalina instead of all Tomcat processes.

Tomcat VM parameter changes under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.