Out of Memory Error Using SBT When Executing Lift Project

Hahnemann picture Hahnemann · Jan 6, 2012 · Viewed 18.8k times · Source

I am using SBT 0.7.7. When I make a change to my Lift project and re-compile via:

  1. jetty-stop
  2. compile
  3. jetty-run

I get the following error:

Error during sbt execution: java.lang.OutOfMemoryError: PermGen space

I have the following defined inside /opt/local/bin/sbt-0.7:

# Is the location of the SBT launcher JAR file.
LAUNCHJAR="/opt/local/share/sbt-0.7/sbt-launch-0.7.7.jar"

# Ensure enough heap space is created for SBT.
if [ -z "$JAVA_OPTS" ]; then
JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M"
fi

# Assume java is already in the shell path.
exec java $JAVA_OPTS -jar "$LAUNCHJAR" "$@"

Answer

juice picture juice · Sep 18, 2012

The PermGen is just one of many spaces that as a whole make up the Heap. You could increase the entire heap until the portion that is allocated is big enough for your needs or you could simply increase the allocation toward the PermGen space. In order to do that latter, use

For sbt 0.12.0

export SBT_OPTS=-XX:MaxPermSize=256m

It would be best to put this in your .bash_profile (assuming you are using bash)

For sbt 0.7

In your case increase the -XX:MaxPermSize to something more than 256m. Keeping in mind that needing more than 256m suggests that there may be other issues.