This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Cannot run program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Products » Tomcat
Bookmark " Cannot run program "env": error=12, Cannot allocate memory" Watch " Cannot run program "env": error=12, Cannot allocate memory" New topic
Author Cannot run program "env": error=12, Cannot allocate memory

adam ali ji

Joined: Apr 24, 2009
Posts: 1

I am running tomcat tomcat 5.2.27 on Fedora 10 which is installed on a VPS. VPS has 768MB RAM (As by free command).
I am unable to use maximum available memory by JVM's Xmx512m option.

I am using these options in ..

JAVA_OPTS="$JAVA_OPTS -Xmx256m -Xms128m -XX:MaxPermSize=128m -Dfile.encoding=UTF8 -Duser.timezone=GMT$CATALINA_HOME/conf/jaas.config -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false"

With above options there is an error (However server starts fine)..
The error is Cannot run program "env": error=12, Cannot allocate memory
at java.lang.ProcessBuilder.start(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(

Free command output in above case is:
total used free shared buffers cached
Mem: 786432 184304 602128 0 0 0
-/+ buffers/cache: 184304 602128
Swap: 524288 0 524288

Its shows that there is still enough memory space to use. I use only command line version of fedora(Hence no significant memory use).
More over, to run just the env command it should not require this much memory as shown by free.

This happens when I have specified maximum memory as 256M, but as I have more memory allocated to my VPS,I want to use more as max heap size.
But when I try to change java option to Xmx368m or Xmx512m , it says that it could not allocate this memory to server and server does not starts at all.

I somewhere read similar problem but no solution, Is it because of VPS?
Any body has any idea how it can be resolved?
I agree. Here's the link:
subject: Cannot run program "env": error=12, Cannot allocate memory
It's not a secret anymore!