How to specify JVM maximum heap size
How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
My application does large data arrays processing and needs more memory than JVM gives by default. I know in Java it's specified by "-Xmx" option. How do I set SBT up to use particular "-Xmx" value to run an application with "run" action?
Answer by Synesso for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
There's one way I know of. Set the environment variable JAVA_OPTS.
JAVA_OPTS='-Xmx512m'
I have not found a way to do this as a command parameter.
Answer by Googol Shan for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
If you run sbt on linux shell, you can use:
env JAVA_OPTS="-Xmx512m" sbt run
This is my usually used command to run my sbt project.
Answer by Arne for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
Try this:
class ForkRun(info: ProjectInfo) extends DefaultProject(info) { override def fork = Some(new ForkScalaRun { override def runJVMOptions = super.runJVMOptions ++ Seq("-Xmx512m") override def scalaJars = Seq(buildLibraryJar.asFile, buildCompilerJar.asFile) }) }
Answer by iwein for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
For forked processes you should look at Build.scala
To modify the java options for forked processes you need to specify them in the Build.scala (or whatever you've named your build) like this:
val buildSettings = Defaults.defaultSettings ++ Seq( //? javaOptions += "-Xmx1G", //? )
This will give you the proper options without modifying JAVA_OPTS globally, and it will put custom JAVA_OPTS in an sbt generated start-script
For non forked processes it's most convenient to set the config via sbtopts
or sbtconfig
depending on your sbt version.
Since sbt 0.13.6 .sbtconfig
is deprecated. Modify /usr/local/etc/sbtopts
along these lines:
-J-Xms512M -J-Xmx3536M -J-Xss1M -J-XX:+CMSClassUnloadingEnabled -J-XX:+UseConcMarkSweepGC -J-XX:MaxPermSize=724M -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
You can also create an .sbtopts file in the root of your SBT project using the same syntax as in the /usr/local/etc/sbtopts file. This makes the project self-contained.
Before sbt 0.13.6 you could set the options in .sbtconfig for non forked processes:
Check where sbt is:
$ which sbt /usr/local/bin/sbt
Look at the contents:
$ cat /usr/local/bin/sbt #!/bin/sh test -f ~/.sbtconfig && . ~/.sbtconfig exec java ${SBT_OPTS} -jar /usr/local/Cellar/sbt/0.12.1/libexec/sbt-launch.jar "$@"
Set the correct jvm options to prevent OOM (both regular and PermGen):
$ cat ~/.sbtconfig SBT_OPTS="-Xms512M -Xmx3536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:MaxPermSize=724M"
If you want to set SBT_OPTS only for the current run of sbt you can use env SBT_OPTS=".." sbt
as suggested by Googol Shan. Or you can use the option added in Sbt 12: sbt -mem 2048
. This gets unwieldy for longer lists of options, but it might help if you have different projects with different needs.
Note that CMSClassUnloadingEnabled in concert with UseConcMarkSweepGC helps keep the PermGen space clean, but depending on what frameworks you use you might have an actual leak on PermGen, which eventually forces a restart.
Answer by scrapcodes for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
In sbt version 12 onwards there is an option for this:
$sbt -mem 2048
Answer by Pete Neisen for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
The javaOptions += "-XX:MaxPermSize=1024"
in our build.sbt as referenced by @iwein above worked for us when we were seeing a java.lang.OutOfMemoryError thrown while running Specs2 tests through sbt.
Answer by Brett for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
Use JAVA_OPTS for setting with environment variable.
Use -J-X options to sbt for individual options, e.g. -J-Xmx2048 -J-XX:MaxPermSize=512
Newer versions of sbt have a "-mem" option.
Answer by Piotrek De for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
.sbtconfig
is deprecated starting with SBT 0.13.6
. Instead, I configured these options in /usr/local/etc/sbtopts
in the following way:
-J-Xms512M -J-Xmx3536M -J-Xss1M -J-XX:+CMSClassUnloadingEnabled -J-XX:+UseConcMarkSweepGC -J-XX:MaxPermSize=724M -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Answer by Sajive Kumar for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
The environment variable is _JAVA_OPTIONS, which needs to be set. Once you set _JAVA_OPTIONS, and when you sbt, sbt will show the message using JAVA_OPTIONS and the values.
Alternatively you could set javaOption in the sbt or .scala file e.g
javaOptions += "-Xmx1G"
From sbt shell you could run show javaOptions to see the values that are set.
Answer by Vasya Novikov for How to specify JVM maximum heap size "-Xmx" for running an application with "run" action in SBT?
javaOptions in Test += "-Xmx1G"
This sets the JVM options for tests. Works also with jvm forking (fork in Test := true
).
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment