java - Tomcat7 : Out of memory error occurred when executing shutdown. sh

标签 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请求)。

以下是虚拟机选项:

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

相关文章:

spring - 现有 GWT2 项目的 hibernate ejb3+Tomcat+Openejb 或 Spring+hibernate

java - 准备语句: executeUpdate insert wrongly the raw

java - SonarQube 报告警告 : 'A prepared statement is generated from a non constant string'

java - 我可以在类内编辑 hibernate 实体的字段(例如某些域逻辑)还是会导致一些与代理相关的问题?

APACHE - 如何绕过特定来源 IP 的 SSL?

tomcat - 如何在 Tomcat7 中部署 Grails 3.0.1 war 文件?

java - 访问Tomcat目录路径

java - WEB-INF/context.xml 或 TOMCAT_HOME/conf/server.xml 下的 Tomcat 连接池?

java - 如何测试非法访问异常?

java - 在 Java REST 中将字符串转换为 JSON