记一次服务器内存不足导致的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的线程,再看内存使用情况,一目了然,物理内存不够用了,那解决办法也理所当然要么加内存,要么减少各个程序的占用。
最终才去减少各个程序占用,之后再启动,没再报错。