Insufficient memory for Java Runtime Environment

July 4, 2015 29.9k views
Deployment Java

Hello, I am testing deployment of a JEE application to a droplet with 512MB, and as I start the application server Wildfly (JBoss AS), I received this message:

3:42:45,663 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 75) Initializing Mojarra 2.2.11-jbossorg-1 20150505-1501 for context '/bbword'
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000e2320000, 37601280, 0) failed; error='Cannot allocate memory' (errno=12)
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 37601280 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /opt/wildfly-9.0.0.Final/hs_err_pid761.log

Is there really a sign of memory in the droplet, or something else? I can test the same application on Openshift's free catriage (similar to digitalocean's droplet).

3 Answers

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

There isn't enough RAM for the Java program to run. You can try adding a swap file but in the long term resizing your droplet to 1GB or larger would be a better choice.

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

I got that message too when deploying a PlayFramework app.

You could try passing -mem 512 to your JVM. That worked for me.

Ok, Java is a monster that likes to eat RAM. We all know this. First off, confirm this by running top. I did and saw that java was using 58% of my RAM. I just used Java to compile a new jar file for Minecraft to run. Ok. so I ran ps -e | grep java and got the PID and did a kill -9 [PID]. When calling Java I allocate memory for smoother game play [ java -Xmx2G -Xms2G ...... ]. This sets the ram used at 2GB. Once I ran this again it worked and we are in business. Hope this helps.

Have another answer? Share your knowledge.