November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Native memory allocation (mmap) failed to map XX bytes for committing reserved memory – JDK 1.8 – CentOS 6.7

While trying to check whether java was working I was repeatedly getting the following error:
java -version

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2555904 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
Tried increasing memory allocated to the java process, tried a lot of things mentioned by people online but nothing helped. The server had enough ram, 24GB free.

Turn’s out I had to disable MPROTECT as I was on a hardened kernel. To do this first run:

To find out where java is located run:
which java
Then:

paxctl -c /usr/bin/java

and finally to disable MPROTECT:
paxctl -m /usr/bin/java

This now allows java to run fine, issuing the java -version command at shell no longer throws an error instead shows the version of Java installed which is what you should actually be seeing.

In case you want to turn MPROTECT back on issue the following:

paxctl -M /usr/bin/java

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>