在scala项目上-运行sbt test命令时超出错误GC开销限制
我是scala编程新手,在一个大型scala项目中执行在scala项目上-运行sbt test命令时超出错误GC开销限制,scala,configuration,garbage-collection,sbt,Scala,Configuration,Garbage Collection,Sbt,我是scala编程新手,在一个大型scala项目中执行sbt test命令时,发现GC开销限制超过了错误。有人知道我该如何解决这个问题吗?我得到了朋友们的帮助:) 通过执行-mem选项来增加内存选项,例如: sbt-mem2048测试 其他选项: 对于Mac和Linux用户: 如果我们需要执行很多。我们可以更新.bash\u profile文件并添加以下命令: export SBT_OPTS=“-Xmx2G” 其他解决方案(也适用于Windows): 还有一个特定的sbtopts文件,您可以在其
sbt test
命令时,发现GC开销限制超过了
错误。有人知道我该如何解决这个问题吗?我得到了朋友们的帮助:)
通过执行-mem选项来增加内存选项,例如:
sbt-mem2048测试
其他选项:
对于Mac和Linux用户:
如果我们需要执行很多。我们可以更新.bash\u profile
文件并添加以下命令:
export SBT_OPTS=“-Xmx2G”
其他解决方案(也适用于Windows):
还有一个特定的sbtopts
文件,您可以在其中保存此内存设置:
在Mac/Linux中查找文件:
/usr/local/etc/sbtopts
还是在窗户里
C:\ProgramFiles(x86)\sbt\conf
并添加以下配置:
# set memory options
#
-mem 2048
希望这些提示中的任何一个都能帮助解决此问题。查看位于我的系统上的,位于/usr/share/sbt/bin/sbt
,我们看到以下内容:
declare -r sbt_opts_file=".sbtopts"
declare -r etc_sbt_opts_file="/etc/sbt/sbtopts"
declare -r dist_sbt_opts_file="${sbt_home}/conf/sbtopts"
...
# Here we pull in the default settings configuration.
[[ -f "$dist_sbt_opts_file" ]] && set -- $(loadConfigFile "$dist_sbt_opts_file") "$@"
# Here we pull in the global settings configuration.
[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@"
# Pull in the project-level config file, if it exists.
[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@"
# Pull in the project-level java config, if it exists.
[[ -f ".jvmopts" ]] && export JAVA_OPTS="$JAVA_OPTS $(loadConfigFile .jvmopts)"
run "$@"
因此,我们可以将配置设置放在:
.jvmopts
.sbtopts
/etc/sbt/sbtopts
${sbt_home}/conf/sbtopts
例如,project使用.jvmopts
设置-Xmx3G
。或者我们可以这样做
echo "-mem 2048" >> .sbtopts
关于环境变量sbt-h
文件
JAVA_OPTS environment variable, if unset uses "$java_opts"
.jvmopts if this file exists in the current directory, its contents
are appended to JAVA_OPTS
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
.sbtopts if this file exists in the current directory, its contents
are prepended to the runner args
比如说,
export JAVA_OPTS=-Xmx2G
sbt
应使用2G内存运行sbt
请注意,如果您正在中运行测试,则可以通过build.sbt
中的javaOptions
设置来增加内存,如下所示:
Test / fork := true
Test / javaOptions ++= Seq("-Xmx4G")
是一个有用的工具,可以查看在尝试不同的SBT配置方法时传递给JVM进程的设置。更改为2048,但仍然失败