我是scala编程的新手,并且在一个大型scala项目中执行GC overhead limit exceeded
命令时遇到sbt test
错误。谁知道我该怎么解决?
答案 0 :(得分:3)
我从我的朋友那里得到了帮助:)
通过执行-mem选项来增加内存选项,例如:
sbt -mem 2048 test
其他选项:
对于Mac和Linux用户:
如果我们需要执行很多操作。我们可以更新.bash_profile
文件并添加以下命令:
export SBT_OPTS="-Xmx2G"
其他解决方案(也适用于Windows):
还有一个特定的sbtopts
文件,您可以在其中保留此内存设置:
在Mac / Linux中查找文件:
/usr/local/etc/sbtopts
或在Windows中
C:\Program Files (x86)\sbt\conf
并添加以下配置:
# set memory options
#
-mem 2048
希望这些技巧中的任何一个都能帮助解决此问题的人。
答案 1 :(得分:0)
看看我们系统上位于{
"_id" : ObjectId("5c6830c9a7e056443ce8befe"),
"user_id" : "5c4e1a3cbc446733801b5a54",
"cart_date" : "2019-02-16T15:48:25.464Z",
"activeCart" : true,
"cart_content" : [
{
"_id" : ObjectId("5c6830c9a7e056443ce8beff"),
"product_id" : "1",
"product_quantity" : 2 ****
}
],
"__v" : 0
}
的{{3}},我们看到以下内容:
{
"_id" : ObjectId("5c6830c9a7e056443ce8befe"),
"user_id" : "5c4e1a3cbc446733801b5a54",
"cart_date" : "2019-02-16T15:48:25.464Z",
"activeCart" : true,
"cart_content" : [
{
"_id" : ObjectId("5c6830c9a7e056443ce8beff"),
"product_id" : "1",
"product_quantity" : 1
}, {
"_id" : ObjectId("5c6830c9a7e056443ce8b421"),
"product_id" : "2",
"product_quantity" : 1
],
"__v" : 0
}
因此我们可以将配置设置放入:
/usr/share/sbt/bin/sbt
例如,launcher script for running 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
。或者,我们可以做
.jvmopts
关于环境变量-Xmx3G
文档
echo "-mem 2048" >> .sbtopts
例如,
sbt -h
应使用2G内存运行sbt。
请注意,如果您正在typelevel/cats
中运行测试,则可以通过 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
设置来增加内存,如下所示:
javaOptions
forked JVM是一个有用的工具,可以在尝试以不同方式配置SBT时查看将哪些设置传递给JVM进程。