error=‘Cannot allocate memory‘ (errno=12)

记一次服务器内存不足导致的springboot启动失败
先看报错:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000772280000, 667418624, 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 667418624 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/apps/我的程序名/hs_err_pid166848.log

再看错误日志:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 667418624 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
#   JVM is running with Zero Based Compressed Oops mode in which the Java heap is
#     placed in the first 32GB address space. The Java Heap base address is the
#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
#     to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2799), pid=166848, tid=0x00007f39d6820700
#
# JRE version: OpenJDK Runtime Environment (8.0_282-b08) (build 1.8.0_282-b08)
# Java VM: OpenJDK 64-Bit Server VM (25.282-b08 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
---------------  T H R E A D  ---------------
后续省略

查看服务器启动的java进程

ps aux | grep "java -ja"

如下图:
在这里插入图片描述

可以看到,启动了很多指定内存1G的线程,再看内存使用情况,一目了然,物理内存不够用了,那解决办法也理所当然要么加内存,要么减少各个程序的占用。

最终才去减少各个程序占用,之后再启动,没再报错。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
error='Cannot allocate memory' (errno=12)是一个常见的错误,表示JVM无法分配内存。这通常是由于系统的物理内存不足或交换空间不足导致的。当JVM尝试分配一定数量的内存时,操作系统无法提供足够的空闲内存,从而导致JVM崩溃。 解决这个问题的方法有几种。首先,您可以尝试释放一些不必要的进程或内存资源,以腾出更多的可用内存。您可以通过关闭一些不使用的程序或服务来实现这一点。这样,JVM将有更多的内存可用于分配。 另一种解决方法是修改JVM的默认配置,减少其启动时所需的内存。您可以通过调整JVM的堆大小、栈大小等参数来实现这一点。具体的方法取决于您使用的是哪个JVM版本和配置工具。您可以查阅相关文档或参考其他资源来了解如何修改JVM的配置。 此外,您还可以考虑升级系统的物理内存或增加交换空间的大小,以提供更多的可用内存给JVM使用。这可能需要一些硬件或系统配置方面的操作,具体取决于您的环境和需求。 总结来说,error='Cannot allocate memory' (errno=12)错误表示JVM无法分配足够的内存。您可以通过释放不必要的进程或资源、调整JVM的配置或增加系统的物理内存和交换空间来解决这个问题。具体的解决方法取决于您的环境和需求。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值