49

I have a tomcat as my web-server, it stopped down automatically with the given Error -

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f16a8405000, 12288, 0) failed; error='Cannot allocate memory' (errno=12)

i need to figured it out what actually happened ? and what warning does mean ?

Greesh Kumar
  • 1,847
  • 3
  • 27
  • 44
  • 1
    possible duplicate of [How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?](http://stackoverflow.com/questions/1124771/how-to-solve-java-io-ioexception-error-12-cannot-allocate-memory-calling-run) – legoscia Jun 23 '15 at 13:10
  • What is the OS? Does it have enough resources (RAM?).. On linux see http://stackoverflow.com/questions/29250953/jmeter-out-of-memory-on-linux. – Jayan Jun 05 '16 at 05:34
  • ubuntu 14.04 OS , 16 GB Server – Greesh Kumar Jun 06 '16 at 05:04
  • I had an issue with running java from apache (a similar error). The fix described [here](https://stackoverflow.com/a/52201705/284602). – Andron Sep 06 '18 at 11:38

3 Answers3

56

There is insufficient memory for the Java Runtime Environment to continue.

Native memory allocation (malloc) failed to allocate xxxxx bytes for committing reserved memory.

Possible reasons:

  1. The system is out of physical RAM or swap space
  2. In 32 bit mode, the process size limit was hit

Possible solutions:

  1. Reduce memory load on the system
  2. Increase physical memory or swap space
  3. Check if swap backing store is full
  4. Use 64 bit Java on a 64 bit OS
  5. Decrease Java heap size (-Xmx/-Xms)
  6. Decrease number of Java threads
  7. Decrease Java thread stack sizes (-Xss)
  8. Set larger code cache with -XX:ReservedCodeCacheSize=

If you are on Java 8 or later, please also see this question: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Manisha Bano
  • 1,853
  • 2
  • 22
  • 34
  • 15
    This answer is a copy/paste of what is suggested in the log file generated by the JVM. It would have been more honest to cite this file... But it works (I increased the amount of physical RAM on the machine, a virtual machine in fact). Thanks! – Julien Kronegg Jun 08 '17 at 10:55
  • 1
    Why should be one of the solutions decreasing (!!) Java heap space with -Xms/-Xmx or/and decreasing Java thread stack space with -Xss. I expected that one of these values (or both) must be increased instead... – Steffen Apr 18 '18 at 05:53
  • 4
    @Steffen the reason decreasing max heap space would help is that it constrains the java VM to prevent it asking for more memory than the OS has available. The situation causing the error is that the JVM is asking for memory that the OS doesn't have (meaning the JVM is still under it's max threshold). – gorjusborg May 31 '18 at 20:32
  • There can also be an issue with overcommit settings which may cause a loaded machine to be overly pessimistic about the available memory, and refuse to allocate your request. I ran into this issue with an application that forked itself and had the same memory pages duplicated in each process. Even though they were copy on write, the system was only able to consider the memory usage as if all of these memory pages were duplicated. – Juan Jul 12 '20 at 04:09
  • Lol, I have 32GB of memory and it's still not enough for Java (TM) Runtime (TM) Environment (TM) – szx Sep 01 '22 at 04:14
12

Java was not able to allocate enough memory, i.e. it's not Java's heap limit that's in the way but rather no more memory available to be given to Java by OS. Check that the machine is not running out of memory. And first clean ram or increase ram then check if again there is an out of memory error then increase heap size:

-Xms128m min(heap size)

-Xmx512m max(heap size)

-XX:MaxPermSize max(perm size)

Hack-R
  • 22,422
  • 14
  • 75
  • 131
Brainsbot
  • 121
  • 1
  • 5
  • 1
    mastadminchat03@PRDMASTCHAT03:~$ free : total = 14361104 , used : 6188292, free : 8172812, shared: 428, buffers=57396, cached=1233592 – Greesh Kumar Jun 06 '16 at 05:08
2

There is insufficient memory for the Java Runtime Environment.

I was facing the same issue as shown below.

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000f80f7000, 20729856, 0) failed; error='Cannot allocate memory' (errno=12)

I solved this by using below steps.

There are processes hanging on to files they've accessed on /tmp

Use lsof to check:

lsof | grep deleted

It will list processes, Now you can kill those process which will free the space for you.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jadhav Gaurav
  • 510
  • 5
  • 10