12

I made some modifications to my play project and when I try and run it I get errors.

>play run
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occured. Program will exit.

Is this a common problem? I am fairly inexperienced with the play framework but I have ran my project several times before without encountering this error.

Edit: Information regarding java version.

>java -version
java version "1.7.0_11"
Java(TM) Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode, sharing)
Sujith PS
  • 4,776
  • 3
  • 34
  • 61
  • 1
    Look at this post http://stackoverflow.com/questions/1058471/java-refuses-to-start-could-not-reserve-enough-space-for-object-heap . It might be of your help – Vishal K Feb 01 '13 at 15:35
  • Thanks, I will definitely bookmark that. Oddly enough after another run attempt or 2 I was able to load the project. –  Feb 01 '13 at 15:38
  • It might be possible that Your system could not provide enough memory to `JVM` for proper initialization of JVM . For a fast luck i would suggest you to try `java -Xmx6g` or `java -Xmx1500m` – Vishal K Feb 01 '13 at 15:43
  • possible duplicate of [Could not reserve enough space for object heap](http://stackoverflow.com/questions/4401396/could-not-reserve-enough-space-for-object-heap) – Mihai Soloi Jan 18 '14 at 06:15

1 Answers1

20

In Play framework 2.0.3, <play framework install dir>\framework\build.bat script you need to replace the command line argument for the command below

java -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*

into

java -XX:+CMSClassUnloadingEnabled %DEBUG_PARAM% -Dfile.encoding=UTF8 -Dplay.version="%PLAY_VERSION%" -Dsbt.ivy.home="%~dp0..\repository" -Dplay.home="%~dp0." -Dsbt.boot.properties="file:///%p%sbt/sbt.boot.properties" -jar "%~dp0sbt\sbt-launch.jar" %*

It solved my problem.

For more, refer to this post .

Community
  • 1
  • 1
Sujith PS
  • 4,776
  • 3
  • 34
  • 61
  • Without modifying the `.bat` file (which is called `activator.bat` in my Play! 2.3.8 installation, and is located within my project's root dir), you can also create an environment variable called `JAVA_OPTS` and store the following values there: `-Xms512M -Xmx1024M`. I was able to get my activator up and running again with this modification. – Benjamin Jentsch May 26 '15 at 14:39