3

I installed sbt 0.13.1 from http://www.scala-sbt.org through the msi package.

When I try to start it through a command prompt i get this error

C:\Users\megatron>sbt
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

So I followed the recommendation in the setup notes and added/changed this in the C:\Program Files (x86)\sbt\conf\sbtconfig.txt file.

-Xmx1536M
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=128m
-Xss1M 
-XX:+CMSClassUnloadingEnabled 

This doesn't help either and I still get the same error.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
mrt181
  • 5,080
  • 8
  • 66
  • 86
  • Where do you read about `sbtconfig.txt`, in the setup notes you link to I cannot find references to this file? – 0__ Dec 27 '13 at 11:02
  • I do not use Windows, so just a wild guess: Is `sbt` a batch file? If so, it might look similar to [this one](http://stackoverflow.com/questions/9735879/using-sbt-in-cygwin-run-the-run-of-play2-cant-send-ctrl-d-to-it) (that's an older version from sbt 0.11); in there you should be able to locate either `JAVA_OPTIONS` or a direct call to `java` where you can add those options. [Here](http://stackoverflow.com/questions/18155325/scala-error-occurred-during-initialization-of-vm-on-ubuntu-12-04) is a similar question for Linux, perhaps it helps. – 0__ Dec 27 '13 at 11:09
  • I took a look at the sbt.bat which loads sbtconfig.txt for extra options. It even checks for %JAVA_OPTS% in the environment, to use that instead of sbtconfig.txt. %JAVA_OPTS% is not set on my machine. – mrt181 Dec 27 '13 at 12:14
  • Then just try adding your options directly in place of `JAVA_OPTS` – 0__ Dec 27 '13 at 12:42
  • Just tried this, doesn't help. – mrt181 Dec 27 '13 at 12:54
  • 1
    One of the linux question's answers points out a problem with whitespace occurring in the installation path. You also have whitespace in the sbt location; perhaps try installing it in a different location. Also check the [window setup instructions](http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html#windows), especially try creating a simple `sbt.bat` batch file as outlined in that text. – 0__ Dec 27 '13 at 13:02
  • Whitespace in the path was the problem. Could you please enter this as the answer so I can accept it. – mrt181 Dec 27 '13 at 14:05

2 Answers2

2

It seems you should not have white space characters in the installation path to sbt. You have one in Program Files. Try installing into a different location.

0__
  • 66,707
  • 21
  • 171
  • 266
  • 1
    This isn't an issue on my machine. If this is causing issues, then you should open a ticket. – jsuereth Dec 27 '13 at 17:38
  • 2
    I'm also pretty sure the space character was not the root cause, but quite likely the wrong memory settings when on 32-bit machine or using 32-bit JVM (`x86` in the path). – Jacek Laskowski Dec 28 '13 at 14:48
1

[EDITED, see below]

workaround for me: first try rebooting Windows

I've seen this problem in the past on Windows. Now again with sbt-0.13.5 on Windows 8.1.

By default the sbt installer installs to C:/Program Files (x86)/sbt. I also tried C:/sbt and got the same error while my system appeared to have almost 2G RAM still available. Next, without changing anything else I rebooted and sbt worked from C:/sbt. Then I re-installed using the default C:/Program Files (x86)/sbt path and still sbt works. Of course rebooting isn't a solution.


See related answer. The problem may be that when you are running sbt you are picking up 32-bit JRE (probably via C:/Windows/System32) instead of 64-bit in your path (check with java -version). Apparently the problem is then that although there may be enough memory overall it might not be contiguous that the JVM is requesting.

Community
  • 1
  • 1
Core
  • 410
  • 2
  • 10