16

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" "$@"
alex
  • 479,566
  • 201
  • 878
  • 984
Hahnemann
  • 4,378
  • 6
  • 40
  • 64
  • Possible duplicate: [this question](http://stackoverflow.com/questions/1451648/permgen-problems-with-lift-and-jetty). – Philippe Jan 06 '12 at 01:32
  • Thanks Philippe. I already tried adding those options to my sbt-0.7 but I still get those errors. – Hahnemann Jan 07 '12 at 02:17

2 Answers2

37

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.

juice
  • 1,651
  • 15
  • 11
7

You need to allow java to allocate more memory.

# You may need more or less depending on your project.
export SBT_OPTS=-Xmx1024M

You might revisit some of those other memory settings as well. I'm running SBT 0.11.2, and I have nothing but Xmx specified.

As an aside, I'd be surprised if you actually have any GC issues during a compile. Changing the GC collection strategy more relevant for longer running processes.

robert
  • 1,402
  • 1
  • 15
  • 21
Chewbarkla
  • 329
  • 4
  • 10
  • 3
    "I'd be surprised". Then I suppose you are, since this happens all the time to me when compiling large project. "more relevant for longer running processes"....have you ever compiled Scala? – Paul Draper Feb 14 '15 at 20:33
  • it definitely happens when you use slick w/ slickless to describe large database tables – Andrew Norman Mar 22 '18 at 23:22