NumeroUno
NumeroUno

Reputation: 1150

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. We are trying to run a Java program with -Xmx6000M.
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.

Interesting thing is if I change -Xmx to 3000M, it starts working fine and my program is up and all good.
As per my understanding, Xmx denotes maximum heap memory that a JVM can go upto and it is on demand allocation. 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?
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.

Please advice.

Output of /etc/proc/meminfo is:

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. Can this be the potential reason for OOM?

Upvotes: 0

Views: 3628

Answers (1)

Martin
Martin

Reputation: 145

Java HotSpot VM is split between 3 memory spaces (Java Heap, PermGen, C-Heap). For a 32-bit VM, all these memory spaces compete between each other for memory. Increasing the Java Heap space (with -Xmx) will further reduce capacity of the C-Heap and reserve more memory from the OS.

This is also why reducing -Xmx to 3000M as you did makes your programm work fine.

For more details, see https://javaeesupportpatterns.blogspot.com/2012/03/outofmemoryerror-out-of-swap-space.html

Upvotes: 1

Related Questions