Skip to content

Instantly share code, notes, and snippets.

@kevin-lee
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevin-lee/cef0bbb7ce6580ad2791 to your computer and use it in GitHub Desktop.
Save kevin-lee/cef0bbb7ce6580ad2791 to your computer and use it in GitHub Desktop.
A few tips for sbt

sbt

Change the Default Ivy Home

sbt -Dsbt.ivy.home=/your/local/path/.ivy

Then the dependencies and the other files downloaded for sbt will be stored in the cache folder of the new location.

e.g.)

ivy.home=/your/local/path/.ivy
the cache=/your/local/path/.ivy/cache

Out of Memory Issue

Using /usr/local/etc/sbtopts File

This solution is only for sbt installed using brew on Mac OSX.

If sbt build process causes OutOfMemoryError like,

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded

Add the following lines to the /usr/local/etc/sbtopts file.

-J-XX:+CMSClassUnloadingEnabled
-J-Xmx2048m
-J-XX:MaxMetaspaceSize=512m

Change 2048 in -J-Xmx2048m (It's 2GiB) and 512 in -J-XX:MaxMetaspaceSize=512m as required.

Alternative to sbtopts

The maximum heap size can be set on the fly like

$ sbt -d -J-Xmx1024m compile 

Scala.js may take lots of memory to do full optimization so it might be necessary to do like

$ sbt -d -J-Xmx2048m fullOptJS 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment