我的Tomcat服务器已经运行了好几天了,但是我无法正常关闭它,因为在执行shutdown.sh
时,出现了这样的错误:
# root@iZ94hjppdqzZ:~/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 32 bit mode, the process size limit was hit
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Use 64 bit Java on a 64 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 may 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 have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
因此我必须杀死 Tomcat 才能将其关闭。但奇怪的是,出现这个错误时Tomcat工作正常(可以正常处理web请求)。
以下是虚拟机选项:
-server -Xms1G -Xmx1G -XX:+UseG1GC
我的服务器有 2GB 内存。谁能弄清楚发生了什么? 谢谢!!
最佳答案
这看起来您正在通过以下方式设置内存配置:
JAVA_OPTS="-server -Xms1G -Xmx1G -XX:+UseG1GC"
JAVA_OPTS
环境变量用于 Tomcat 的所有 java 进程,例如用于发送关闭消息的进程。
您需要确定您正在通过设置配置您的 Tomcat 内存:
CATALINA_OPTS="-server -Xms1G -Xmx1G -XX:+UseG1GC"
此设置将仅应用于 Tomcat 进程。其他控制进程将使用默认内存设置正常执行。
关于java - Tomcat7 : Out of memory error occurred when executing shutdown. sh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31644477/