How to set heap size in play/activator?

eaglefreeman picture eaglefreeman · Jan 22, 2015 · Viewed 8.1k times · Source

I get a "java.lang.OutOfMemoryError: Java heap space" when running activator. I would like to set the heap to unlimited size. I read somewhere else that I need to change SBT_OPTS or _JAVA_OPTION somehow like this:

export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M  -Duser.timezone=GMT"

I could not find any documentation on this anywhere.

Answer

Havoc P picture Havoc P · Jan 23, 2015

tl;dr activator -help

You can use JAVA_OPTS (may affect other java programs), SBT_OPTS (also affects sbt), ACTIVATOR_OPTS (only affects activator) and there's also a -mem flag you can use.

I think -J-Xmx512M would also work.

➜  ~ activator -help
Usage: activator <command> [options]

  Command:
  ui                 Start the Activator UI
  new [name] [template-id]  Create a new project with [name] using template [template-id]
  list-templates     Print all available template names
  -h | -help         Print this message

  Options:
  -v | -verbose      Make this runner chattier
  -d | -debug        Set sbt log level to debug
  -mem <integer>     Set memory options (default: , which is -Xms1024m -Xmx1024m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m)
  -jvm-debug <port>  Turn on JVM debugging, open at the given port.

  # java version (default: java from PATH, currently java version "1.8.0_25")
  -java-home <path>  Alternate JAVA_HOME

  # jvm options and output control
  -Dkey=val          Pass -Dkey=val directly to the java runtime
  -J-X               Pass option -X directly to the java runtime
                     (-J is stripped)

  # environment variables (read from context)
  JAVA_OPTS          Environment variable, if unset uses ""
  SBT_OPTS           Environment variable, if unset uses ""
  ACTIVATOR_OPTS     Environment variable, if unset uses ""

In the case of duplicated or conflicting options, the order above
shows precedence: environment variables lowest, command line options highest.