[英]High XMX: java.lang.outofmemory native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
I did search this issue on net but could not find a possible solution or explanation.我确实在网上搜索过这个问题,但找不到可能的解决方案或解释。
We have a CentOS 6 VM with 8 GB RAM, 64 bit, Open JDK 1.8.我们有一个 CentOS 6 VM,8 GB RAM,64 位,Open JDK 1.8。 We are trying to run a Java program with -Xmx6000M.我们正在尝试使用 -Xmx6000M 运行 Java 程序。
It just crashes on start with following out of memory error:它只是在启动时崩溃并出现内存不足错误:
native memory allocation (malloc) failed to allocate 32756 bytes for ChunkPool::allocate
It just executes starting few lines of the code (no much memory allocation there <500MB) and crashes continously.它只是开始执行几行代码(没有太多内存分配<500MB)并连续崩溃。
Interesting thing is if I change -Xmx to 3000M, it starts working fine and my program is up and all good.有趣的是,如果我将 -Xmx 更改为 3000M,它开始工作正常,我的程序启动并且一切正常。
As per my understanding, Xmx denotes maximum heap memory that a JVM can go upto and it is on demand allocation.根据我的理解,Xmx 表示 JVM 可以达到的最大堆内存,它是按需分配的。 So, I am unable to get how is it causing the crash even JVM did not reach 1 GB of heap and how reducing Xmx is solving it?所以,即使 JVM 没有达到 1 GB 的堆,我也不知道它是如何导致崩溃的,以及如何减少 Xmx 来解决它?
I know if OS is unable to provide the required memory, JVM can crash with OOM but here OS has always more than 3 GB of free memory.我知道如果操作系统无法提供所需的内存,JVM 可能会因 OOM 崩溃,但这里操作系统总是有超过 3 GB 的可用内存。
Please advice.请指教。
Output of /etc/proc/meminfo is: /etc/proc/meminfo 的输出是:
MemTotal: 8061104 kB
MemFree: 4905068 kB
Buffers: 172920 kB
Cached: 1828412 kB
SwapCached: 0 kB
Active: 1751828 kB
Inactive: 1129956 kB
Active(anon): 872840 kB
Inactive(anon): 58348 kB
Active(file): 878988 kB
Inactive(file): 1071608 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 4194300 kB
SwapFree: 4194300 kB
Dirty: 24 kB
Writeback: 0 kB
AnonPages: 880488 kB
Mapped: 334788 kB
Shmem: 50740 kB
Slab: 133388 kB
SReclaimable: 92196 kB
SUnreclaim: 41192 kB
KernelStack: 6880 kB
PageTables: 23236 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 8224852 kB
Committed_AS: 1534484 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 185660 kB
VmallocChunk: 34359545792 kB
HardwareCorrupted: 0 kB
AnonHugePages: 493568 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 251904 kB
DirectMap2M: 7088128 kB
DirectMap1G: 1048576 kB
UPDATE One thing we noticed that swap memory on this OS is not working, it always show 0 KB in used.更新我们注意到此操作系统上的交换内存不起作用的一件事,它始终显示 0 KB in used。 Can this be the potential reason for OOM?这可能是 OOM 的潜在原因吗?
Java HotSpot VM is split between 3 memory spaces (Java Heap, PermGen, C-Heap). Java HotSpot VM 分为 3 个内存空间(Java Heap、PermGen、C-Heap)。 For a 32-bit VM, all these memory spaces compete between each other for memory.对于 32 位 VM,所有这些内存空间都相互竞争内存。 Increasing the Java Heap space (with -Xmx) will further reduce capacity of the C-Heap and reserve more memory from the OS.增加 Java 堆空间(使用 -Xmx)将进一步减少 C 堆的容量并从操作系统保留更多内存。
This is also why reducing -Xmx to 3000M as you did makes your programm work fine.这也是为什么像您一样将 -Xmx 减少到 3000M 会使您的程序正常工作的原因。
For more details, see https://javaeesupportpatterns.blogspot.com/2012/03/outofmemoryerror-out-of-swap-space.html更多详情请参见https://javaeesupportpatterns.blogspot.com/2012/03/outofmemoryerror-out-of-swap-space.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.