My Build.scala file contents.
val commonSettings = Seq(
version := "1.0.0",
organization := "com.collective",
scalaVersion := "2.11.4",
scalacOptions ++= List(
"-encoding", "UTF-8",
"-target:jvm-1.7",
"-feature",
"-unchecked",
"-deprecation",
"-Xlint",
"-Xfatal-warnings"
),
resolvers ++= Seq(
"ConJars" at "http://conjars.org/repo"
),
javaOptions in run += "-Xms256M -Xmx2G -XX:MaxPermSize=1024M -XX:+UseConcMarkSweepGC"
)
lazy val segmentFetcher = Project("segments-fetcher", file("."))
.settings(commonSettings: _*)
)
However, when I execute
sbt run
and look in the jconsole, the heap size I set in the Build.scala is not picked up. It just shows -Xmx512M. Can anyone please let me know how we force sbt to pick the heap space from the project build file?
Thanks!
If you want to change the heap size, you need to tell sbt to fork another JVM (this applies to any JVM option by the way). You can use the fork
setting to do so:
fork in run := true
Also, you want to make sure, that your options are properly separated (there is no additional parsing done by sbt):
javaOptions in run ++= Seq(
"-Xms256M", "-Xmx2G", "-XX:MaxPermSize=1024M", "-XX:+UseConcMarkSweepGC")
Alternatively, you can set the heap size in the sbt runner. If you are using normal sbt, you can modify the launcher script directly. If you are using sbt-extras, you can pass arguments to the JVM using the -J
flag:
sbt -J-Xmx2G # etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With