This page is no longer maintained — Please continue to the home page at www.scala-lang.org

How to give scalac more heap memory

3 replies
Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.

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-

Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.
Re: How to give scalac more heap memory

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-
>

ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
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.

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
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:
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.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland