- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
How to give scalac more heap memory
Sat, 2010-01-02, 18:13
hi,
my scala project doesn't compile any more, scalac always quits with
java.lang.OutOfMemoryError: Java heap space
(after very long compilation, more than 1 1/2 minutes for 53 files, don't know if this is normal).
now i try to increase the heap space, but without success.
java.lang.OutOfMemoryError: Java heap space
$ scalac -Xmx1024m ...
scalac error: Parameter '-Xmx1024m' is not recognised by Scalac.
i also tried -J-Xmx1024m which netbeans uses, the same, not recognised. so how do i set the max heap size?
thanks, -sciss-
Sat, 2010-01-02, 18:47
#2
Re: How to give scalac more heap memory
On my system, "scalac" is just a simple shell script around invoking java on scala.tools.nsc.Main. You could tweak this to increase the memory limit. My default Ubuntu 2.7.3 install, for instance, says
#!/bin/sh
JAVA_DIR=/usr/share/java
SCALAC_CLASSPATH=$JAVA_DIR/scala-library.jar:$JAVA_DIR/scala-compiler.jar
exec ${JAVACMD:=java} ${JAVA_OPTS:=-Xmx256M -Xms16M} \
-Xbootclasspath/a:$SCALAC_CLASSPATH \
-classpath $SCALAC_CLASSPATH -Dscala.boot.class.path=$SCALAC_CLASSPATH \
scala.tools.nsc.Main "$@"
And it'd be pretty easy to go in and change the -Xmx256M to something bigger.
Hopefully you can do something similar.
--Rex
P.S. Changing scalac doesn't affect fsc. You'll have to set that one separately.
#!/bin/sh
JAVA_DIR=/usr/share/java
SCALAC_CLASSPATH=$JAVA_DIR/scala-library.jar:$JAVA_DIR/scala-compiler.jar
exec ${JAVACMD:=java} ${JAVA_OPTS:=-Xmx256M -Xms16M} \
-Xbootclasspath/a:$SCALAC_CLASSPATH \
-classpath $SCALAC_CLASSPATH -Dscala.boot.class.path=$SCALAC_CLASSPATH \
scala.tools.nsc.Main "$@"
And it'd be pretty easy to go in and change the -Xmx256M to something bigger.
Hopefully you can do something similar.
--Rex
P.S. Changing scalac doesn't affect fsc. You'll have to set that one separately.
Sat, 2010-01-02, 18:57
#3
Re: How to give scalac more heap memory
Set JAVA_OPTS to -Xmx1024m.
On Sat, Jan 2, 2010 at 3:12 PM, Sciss <contact@sciss.de> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Sat, Jan 2, 2010 at 3:12 PM, Sciss <contact@sciss.de> wrote:
hi,
my scala project doesn't compile any more, scalac always quits with
java.lang.OutOfMemoryError: Java heap space
(after very long compilation, more than 1 1/2 minutes for 53 files, don't know if this is normal).
now i try to increase the heap space, but without success.
java.lang.OutOfMemoryError: Java heap space
$ scalac -Xmx1024m ...
scalac error: Parameter '-Xmx1024m' is not recognised by Scalac.
i also tried -J-Xmx1024m which netbeans uses, the same, not recognised. so how do i set the max heap size?
thanks, -sciss-
--
Daniel C. Sobral
I travel to the future all the time.
i should add that i build with the netbeans plugin. my netbeans.conf has this already:
netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-Xmx1024m -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled"
but it seems that Xmx is not propagated to scalac.....
Am 02.01.2010 um 17:12 schrieb Sciss:
> hi,
>
> my scala project doesn't compile any more, scalac always quits with
>
> java.lang.OutOfMemoryError: Java heap space
>
> (after very long compilation, more than 1 1/2 minutes for 53 files, don't know if this is normal).
>
> now i try to increase the heap space, but without success.
>
> java.lang.OutOfMemoryError: Java heap space
>
> $ scalac -Xmx1024m ...
> scalac error: Parameter '-Xmx1024m' is not recognised by Scalac.
>
> i also tried -J-Xmx1024m which netbeans uses, the same, not recognised. so how do i set the max heap size?
>
>
> thanks, -sciss-
>