Skip to content

Instantly share code, notes, and snippets.

@guersam
Created July 11, 2014 02:34
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 guersam/49c4dca01ee19e62700f to your computer and use it in GitHub Desktop.
Save guersam/49c4dca01ee19e62700f to your computer and use it in GitHub Desktop.
SBT: MaxPermSize or MaxMetaspaceSize according to the current Java version
javaOptions in (Test, test) := {
val versionParse = """(\d+)\.(\d+)""".r
val permOrMetaspace =
sys.props ("java.specification.version") match {
case versionParse (maj, min) =>
val major = maj.toInt
val minor = min.toInt
if (major > 1 || major == 1 && minor >= 8) "Metaspace" else "Perm"
case _ =>
sys.error ("Unable to determine Java version")
}
Seq("-Xmx256m", s"-XX:Max${permOrMetaspace}Size=128M")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment