启动项目报错 failed; error='Cannot allocate memory' (errno=12)服务器内存不足

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000090000000, 1879048192, 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 1879048192 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /data/dubbo/rkang-all-services/hs_err_pid16708.log

报错信息显示项目配置的启动内存比服务器空闲内存更大。

解决办法:由于服务器目前专门用于测试本项目,于是重启,系统内存恢复正常

重启后linux操作系统后,重新启动docker中的容器,启动redis时使用命令

docker run -d --name myredis -p 6379:6379 redis --requirepass "TzRQ76AfejLrBS5Z"创建容器启动并添加密码

报错docker: Error response from daemon: Conflict. The container name "/myredis" is already in use by container "4b70747bc8a7dab6aa266b3114d96e19bdc80e991bb072f9ec647e63fb8ae62e". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.

之前运行docker容器还没有退出,导致出现容器重名情况

docker rm 4b70747bc8a7dab6aa266b3114d96e19bdc80e991bb072f9ec647e63fb8ae62e
删除镜像id

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

后来多次出现服务器空闲内存不足的情况,经查,是由于每次启动tomcat后,执行tomcat的shutdown.sh脚本关闭容器时都有残留进程占用较多的内存资源,而且重复启动关闭残留进程越来越多,最终使linux系统的可分配内存小于容器启动所需内存,导致项目启动失败。

解决方法:通过ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head取进程占用内存(MEM)最高的前10个进程,

通过:kill -9 进程id

杀死残留进程,free查看内存占用情况,内存已释放,问题解决

你可能感兴趣的:(工作中遇到的问题)