Increase JVM heap size for Scala?

I have a Scala data processing tool that does not work with java.lang.OutOfMemoryError exception. The tool should make a couple of passes on a large data file (the one I'm working on is more than 700 MB), so it would be convenient if the whole thing could be stored in memory.

I run the tool from the command line or from a Bash script using the scala runner. How to increase JVM heap size for this? I tried passing -Xmx1024m , but it does not recognize this argument. I am using the nightly build of Scala 2.8.0 (r18678).

+46
heap command-line scala jvm
Sep 17 '09 at 21:09
source share
5 answers

The JAVA_OPTS environment variable is used to specify the parameters passed to the java command. See Scala manpage for more details.

+25
Sep 18 '09 at 6:00
source share

You can pass JVM parameters through -J. For example.

 scala -J-Xmx2g ... 
+108
Aug 20 '11 at 19:52
source share

Based on Joe's suggestion, I looked at the scala program, which is a Bash script that calls java with various scala arguments. It allows you to pass additional command line arguments to Java through the JAVA_OPTS environment variable. This way you can increase the heap size like this:

 JAVA_OPTS="-Xmx2g" scala classname arguments... 
+21
Sep 17 '09 at 21:36
source share

Change JAVA_OPTS .

+2
Sep 17 '09 at 21:36
source share

As a hack, you can edit the scala/bin/scala file to edit the parameters for the java command. Not really.

0
Sep 17 '09 at 21:17
source share



All Articles