Java 严重错误文件显示内存不足,而堆转储要小得多

Java fatal error file showing insufficient memory while heap dump is much smaller

我是 运行 基于 Java 的应用程序,由于内存不足,它正在崩溃。 hs_err 的一些输出片段:

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 24696061952 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=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error 
#
# JRE version:  (8.0_275-b01) (build )
# Java VM: OpenJDK 64-Bit Server VM
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#

但是当我进行堆转储时,它显示大约 8GB 的​​内存。我的 jvm 参数是:-Xmx30720m -Xms30720m -Xmn7168m -Xss8m

top命令显示

 PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 20   0 82.7g  36g  33m S 10.6 61.9  63594:19 java

/proc/meminfo

/proc/meminfo:
MemTotal:       61833192 kB
MemFree:         2235872 kB
MemAvailable:   20808016 kB
Buffers:          213036 kB
Cached:         17876428 kB
SwapCached:            0 kB
Active:         55994452 kB
Inactive:        1816412 kB
Active(anon):   39721444 kB
Inactive(anon):      132 kB
Active(file):   16273008 kB
Inactive(file):  1816280 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:              1312 kB
Writeback:             0 kB
AnonPages:      39721564 kB
Mapped:           107292 kB
Shmem:               140 kB
Slab:            1280320 kB
SReclaimable:    1121808 kB
SUnreclaim:       158512 kB
KernelStack:       67824 kB
PageTables:       103072 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    30916596 kB
Committed_AS:   75073316 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
AnonHugePages:         0 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       12288 kB
DirectMap2M:    62902272 kB

我不明白如何在此处进行调试,因为堆转储中没有显示任何内容,与健康 运行 应用程序的堆转储相比,堆转储更小。知道如何识别程序的哪一部分占用了内存吗?

您已使用 -Xms 强制 JVM 在 JVM 启动时获得约 30GB。

它尝试过,但失败了。它只获得了8GB。它需要另外 22 GB 但无法获得。这就是错误消息告诉您的内容。这与堆只有 8GB 的​​转储一致。

您要求的比 OS 所能提供的更多。您需要弄清楚 OS 中的一般情况。

您的应用程序代码可能不涉及。 JVM 仍在根据您的命令行选项初始化其堆。