centos启动tomcat报错 failed; error=‘Cannot allocate memory‘ (errno=12)服务器内存不足

centos启动tomcat报错 failed; error=‘Cannot allocate memory’ (errno=12)服务器内存不足

1. 问题

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 358088704, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 358088704 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/platform/tomcat/apache-tomcat-9.0.31/bin/hs_err_pid21205.log
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 358088704, 0) failed; error='Cannot allocate memory' (errno=12)
报错信息显示项目配置的启动内存比服务器空闲内存更大。

2. 解决方法

(1)杀死没有用的进程
使用命令ps -ef查看正在运行的进程,如果确定无用,使用命令kill -9 pid杀死进程

一次性杀死多个java进程:pkill java

(2)扩大内存
① 使用命令sysctl -a|grep vm.max_map_count查询内存大小
在这里插入图片描述
② 调整内存大小为默认的4倍

临时修改:
[root@localhost ~]# sysctl -w vm.max_map_count=262144
永久修改:

直接写到/etc/sysctl.conf中,然后执行sysctl -p

[root@localhost ~]# vim /etc/sysctl.conf
 vm.max_map_count=262144
[root@localhost ~]# sysctl -p

③ 查看修改结果

[root@localhost ~]# sysctl -a|grep vm.max_map_count
vm.max_map_count = 262144
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值