How to set up metaspace using SBT

I am trying to configure metaspace for SBT

export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxMetaspaceSize=512M -XX:MetaspaceSize=256M -Xms2G -Xmx2G" 

but when I run sbt -v , I have the following output:

 [process_args] java_version = '1.8.0_11' # Executing command line: java -XX:+CMSClassUnloadingEnabled -XX:MaxMetaspaceSize=512M -XX:MetaspaceSize=256M -Xms2G -Xmx2G -Xms1024m -Xmx1024m -XX:ReservedCodeCacheSize=128m -XX:MaxMetaspaceSize=256m -jar /usr/local/Cellar/sbt/0.13.7/libexec/sbt-launch.jar 

The problem is that my custom value for MaxMetaspaceSize overridden by another value, as shown above in the output.


SBT Version: 0.13.7

Java Version: 1.8

OS: OSX

+6
source share
4 answers

(copied from a respected colleague who found a solution)

 sbt -mem 2048 

=>

 -Xms2048m -Xmx2048m -XX:ReservedCodeCacheSize=256m -XX:MaxMetaspaceSize=512m 

The default meta search is based on the xmx value specified in the "-mem" option; -)

+24
source

When using sbt 0.13.6 or higher, you can create a .sbtopts file in the root of your project with:

 -J-XX:MaxMetaspaceSize=512M 
+4
source

It seems that the memory parameters are correctly processed only if they are specified in JAVA_OPTS

export JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxMetaspaceSize=512M -XX:MetaspaceSize=256M -Xms2G -Xmx2G"

gives

 sbt -v [process_args] java_version = '1.8.0_40' # Executing command line: java -XX:+CMSClassUnloadingEnabled -XX:MaxMetaspaceSize=512M -XX:MetaspaceSize=256M -Xms2G -Xmx2G -jar /usr/local/Cellar/sbt/0.13.8/libexec/sbt-launch.jar [info] Loading global plugins from /Users/ant/.sbt/0.13/plugins [info] Set current project to ant (in build file:/Users/ant/) > 

Not sure if this is a bug or feature

+3
source
 export SBT_OPTS="-XX:MaxMetaspaceSize=512m -Xms1024m -Xmx1024m" 

works for me in sbt 0.13.11:

 sbt -v [process_args] java_version = '1.8.0_91' # Executing command line: java -XX:MaxMetaspaceSize=512m -Xms1024m -Xmx1024m -jar 
+2
source

Source: https://habr.com/ru/post/982957/


All Articles