9

My system is Mint 12 64bit.

I've installed the typesafe stack and created a new play application. Without modifying the code I've tried to run it. This is the output:

http://pastebin.com/6XwmsbAE

Play complains with this error message:

IOException: Cannot run program "javac": java.io.IOException: error=12, Cannot allocate memory 

How can I fix this ?

UPDATE:

@Mef

Ok you were definitely right. I've increased the initial RAM from 1 GB to 2 GB (running this on virtualbox). Compiling worked exactly once.

Unfortunately java has made up his mind that even 2 GB aren't enough: Running eclipse and firefox my system uses 1 GB. Then I start sbt and the memory usage rises to about 1.2 GB. One might think that this is sufficient. It isn't. Compilation fails with the same error although 800 MB are still available. Moreover after trying to compile the application the memory usage goes up to 1.6 GB. Strangely enough even while compiling the project it never reaches 2 GB but peaks at about 1.8 GB.

Nevertheless I've tried again and fed 3 gigs of RAM to the virtual machine. Now compiling and running the application works fine. As another miracle with 3 GB available the memory usage never rises above 1.6 GB and stays well below the maximum of 1.8 GB that I saw in the 2 GB iteration.

lhk
  • 27,458
  • 30
  • 122
  • 201
  • 2
    Most likely you really ran out of memory. I don't think this is Play related... – Leo Mar 19 '12 at 20:32
  • I've got 1gb ram. It would surprise me if that was the problem but since im using virtualbox i can easily increase the memory. Ill update the question accordingly after I've tried again – lhk Mar 19 '12 at 20:50
  • You were right. 1GB isn't enough. I've tried again with 2GB and everything worked fine – lhk Mar 20 '12 at 15:54

3 Answers3

17

Actually this is not entirely a system error: tweaking the play config files will allow you to make it work on a system with less than 1GB of memory.

In play-2.0.4/framework/build (or build.bat), you just need to change

java ${DEBUG_PARAM} -Xms512M -Xmx1536M ...

to

java ${DEBUG_PARAM} -Xms128M -Xmx512M ...

Now there can be other issues running play with less memory, but at least the basic setup works.

Joel Arnold
  • 1,201
  • 13
  • 28
  • +1 for the great answer. I already moved on and am now working on another project but I'm sure that this can help other developers. – lhk Nov 19 '12 at 16:31
  • 1
    I'm using `java_opts="-Xms128M -Xmx512M" ./activator` to the same effect, a few years later. – Patrick McLaren Oct 15 '14 at 18:29
3

Since this is a general javac error, I doubt that it is Play related. Most likely you really ran out of memory.

Leo
  • 37,640
  • 8
  • 75
  • 100
1

This is very well described in another post and it seems to be a problem with OpenJDK.

How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?

Try the following:

# echo 1 > /proc/sys/vm/overcommit_memory

This has worked for me :-)

Community
  • 1
  • 1
tuxdna
  • 8,257
  • 4
  • 43
  • 61