我有内存泄漏,服务器因内存不足错误而崩溃。
崩溃后的日志说:
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1048576 bytes for committing reserved memory.
# 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 (os_linux.cpp:2743), pid=16671, tid=0x00007f93ec710700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_191-b12) (build 1.8.0_191-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
# Core dump written. Default location: /home/mcraft/servers/survival1/core or core.16671
#
日志说进行了内存转储:
Core dump written. Default location: /home/mcraft/servers/survival1/core or core.16671
但这不是真的,没有转储!
而且奇怪的是,这不是我在 VM Options 中指定的文件夹:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/survival.hprof
磁盘上有足够的内存,有258G可用,我查看了df -H。
debian 9 系统,输出java -version:
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
完成 start.sh:
ulimit -c unlimited
screen -dmS server bash -c "ulimit -c unlimited; \
java \
-Xms2G \
-Xmx5500M \
-Dfile.encoding=UTF-8 \
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder \
-XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=35 -XX:+AlwaysPreTouch -XX:+ParallelRefProcEnabled -Dusing.aikars.flags=mcflags.emc.gs \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/survival.hprof \
-jar core.jar"
- 为什么不进行转储?
- 为什么它说它是在我指定的错误文件夹中制作的?
一般来说,现在我了解到服务器因 RAM 内存不足而崩溃,在这种情况下,它被写入
The system is out of physical RAM or swap space. 在这种情况下,不会进行转储。仅当堆不够时才进行转储。为了让一切正常工作,您需要降低 Java 应用程序的最大内存阈值,以便分配的堆大小适合 RAM。