Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase JVM heap size for Scala?

I have a Scala data processing tool which is failing with a java.lang.OutOfMemoryError exception. The tool needs to make a couple passes over a large data file (the one I'm working on is over 700MB), so it would be convenient if the entire thing could be stored in memory.

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

like image 570
Jay Conrod Avatar asked Sep 17 '09 21:09

Jay Conrod


People also ask

How can I increase my SBT memory?

Increase Memory for sbt and Maven It is possible to start Maven and sbt with increased memory. We recommend you increase the Maximum Metaspace size and the Thread Stack size. These values can be set using -Xss2M -XX:MaxMetaspaceSize=1024M . The exact values may depend on your hardware and your code base.

How do I increase allocated heap size?

1)Change the gradle. properties file and change the heap size as per your requirement. 2)"Edit Custom VM Options" from the Help menu. It will open studio.

Does increasing heap size improve performance?

You can improve performance by increasing your heap size or using a different garbage collector. In general, for long-running server applications, use the J2SE throughput collector on machines with multiple processors (-XX:+AggressiveHeap) and as large a heap as you can fit in the free memory of your machine.


2 Answers

You can pass options to the JVM via -J. E.g.,

scala -J-Xmx2g ... 
like image 185
Geoffrey Irving Avatar answered Sep 21 '22 10:09

Geoffrey Irving


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

like image 29
Synesso Avatar answered Sep 20 '22 10:09

Synesso