64位Ubuntu14.04 tomcat日志报错 There is insufficient memory for the Java Runtime Environment to continue

本文分析了一起Tomcat应用因内存不足导致502错误的情况,并提供了详细的故障排查及解决方案,包括调整系统限制和优化Java虚拟机参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发现一个应用报错502,查看日志后得知错误信息

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000007d3000000, 536870912, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 536870912 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /data/tomcat/bin/hs_err_pid26832.log

ps -ef是看不到这个应用的。

查看/data/tomcat/bin/hs_err_pid26832.log得知

# There is insufficient memory for the Java Runtime Environment to continue.
# Cannot create GC thread. Out of system resources.
# 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 (gcTaskThread.cpp:46), pid=17285, tid=47629249568816
#
# JRE version: 6.0_43-b01
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.14-b01 mixed mode linux-amd64 compressed oops)

从日志中分析,可能原因有两个:

一、可能物理内存不足

二、在32位操作系统下,系统进程数达到上限了。

然后分析服务器内存,可用物理内存以及swap空间都足够,问题可能发生在系统进程数达到上限(我的64位操作系统也是这个问题)。

通过命令查看系统限制:ulimit -a查看open files的值为1024,不够大,尝试通过设大该值:

1、vi  /etc/security/limits.conf

2、在文件最下方加上如下代码   root - nofile 65535   保存(ubuntu下不能使用* - nofile 65535,不起作用,必须注明用户

ssh退出后重新登录

此时通过ulimit -a或ulimit -n可以得到结果65535

启动tomcat问题解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值