Tomcat7:执行shutdown.sh时发生内存不足错误

时间:2015-07-27 03:23:40

标签: java tomcat

我的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请求)。

以下是VM选项:

-server -Xms1G -Xmx1G -XX:+UseG1GC

我的服务器有2GB内存。谁能弄明白发生了什么? 谢谢!

1 个答案:

答案 0 :(得分:5)

这看起来像是通过以下方式设置内存配置:

JAVA_OPTS="-server -Xms1G -Xmx1G -XX:+UseG1GC"

JAVA_OPTS环境变量用于所有Tomcat的java进程,例如用于发送关闭消息的进程。

您需要确定是否通过设置:

来配置Tomcat内存
CATALINA_OPTS="-server -Xms1G -Xmx1G -XX:+UseG1GC"

此设置仅适用于Tomcat进程。其他控制进程将使用默认内存设置执行正常。