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).
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.
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.
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.
You can pass options to the JVM via -J. E.g.,
scala -J-Xmx2g ...
The JAVA_OPTS environment variable is used to specify the options passed to the java command. See the Scala manpage for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With