sbt의 힙 크기를 설정하는 방법은 무엇입니까?
SBT 0.12.0을 사용하고 있습니다. 나는 스택 오버플로에 대한 다른 답변을 읽고 따라 왔지만 그중 어느 것도 도움이되지 않습니다.
ForkRun
클래스 생성 -sbt를 사용하는 동안 분기 된 프로세스를 관찰하지 않았습니다.- 환경 변수 설정
JAVA_OPTS
-설정되었지만 sbt의 프로세스 명령 줄에서 전혀 사용하지 않는 것 같습니다. sbt -J-Xmx2G
sbt 프로세스 명령 줄에 매개 변수를 추가하지만-Xmx1536m
추가 된 매개 변수 대신 sbt 에서 이전 값 을 사용합니다.
내가 뭔가를 놓치고 있습니까? 테스트 및 테스트를 모두 수행 할 때 sbt 0.12의 힙 크기를 어떻게 설정 run
합니까?
bash_profileSBT_OPTS
에서 사용하는 것이 필요합니다 .
export SBT_OPTS="-Xmx1536M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
업데이트 : 2G 힙 공간을 얻으려면 다음을 사용할 수 있습니다.
export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
참고 : SBT는 최신 버전이어야합니다.
의 이전 버전 sbt
에는 이러한 설정을 무시하는 버그가 포함되어 있으며 Mac brew upgrade sbt
용 최신 버전 sbt
(brew 설치 가정) (Linux 용 IDK)을 사용합니다. https://github.com/sbt/sbt/issues/2945#issuecomment-277490848
2015 년 3 월부터 Homebrew 와 함께 OSX 에서 sbt를 사용 하는 경우 파일을 편집해야합니다./usr/local/etc/sbtopts
예 :
# set memory options
#
#-mem <integer>
-mem 2048
"sbt -mem 23000 run"이 저에게 효과적입니다.
해결책을 찾았습니다. JVM 힙 크기를 지정하는 방법에 관계없이 SBT 실행 파일이 이미 무시되었으므로 작동하지 않습니다.
SBT 실행 파일에는 다음과 같은 줄이 있습니다.
. /usr/share/sbt/sbt-launch-lib.bash
그래서 파일을 편집했습니다.
# run sbt
execRunner "$java_cmd" \
${SBT_OPTS:-$default_sbt_opts} \
- $(get_mem_opts $sbt_mem) \
${java_opts} \
${java_args[@]} \
-jar "$sbt_jar" \
"${sbt_commands[@]}" \
"${residual_args[@]}"
-
라인을 제거하십시오 .
이제 SBT를 실행할 때 더 이상 JVM 힙 크기 설정을 재정의하지 않습니다. @Noan의 대답을 사용하여 힙 크기 설정을 지정할 수 있습니다.
또는 :
sbt -J-Xmx4G -J-Xms4G
Windows에서 sbt 0.13.9.2의 경우 JAVA_OPTS
원하는 jvm 옵션 으로 설정해야합니다 .
> set JAVA_OPTS=-Xmx1G
> sbt assembly
sbt.bat
스크립트에서의 기본값을로드 conf\sbtconfig.txt
에 CFG_OPTS
있지만 사용 JAVA_OPTS
설정하면 대신.
관련 발췌 sbt.bat
:
rem FIRST we load the config file of extra options.
set FN=%SBT_HOME%\..\conf\sbtconfig.txt
set CFG_OPTS=
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO (
set DO_NOT_REUSE_ME=%%i
rem ZOMG (Part #2) WE use !! here to delay the expansion of
rem CFG_OPTS, otherwise it remains "" for this loop.
set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME!
)
. . . (건너 뛰기) . . .
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
set _JAVA_OPTS=%JAVA_OPTS%
if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS%
:run
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %*
SBT를 직접 설치하여 Mac OS X에서 이와 같은 문제를 해결하려고했습니다. homebrew를 통해 SBT를 설치 한 경우 /usr/local/bin/sbt
파일이 다음과 같으 므로 명확합니다.
#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
exec java -Xmx512M ${SBT_OPTS} -jar /usr/local/Cellar/sbt/0.12.3/libexec/sbt-launch.jar "$@"
즉, 입력 한 모든 설정이 유지 SBT_OPTS
됩니다 (-Xmx가 우선 적용됨). 또한 스크립트의 첫 번째 줄은 ~/.sbtconfig
존재하는 경우 모든 명령을 실행 하므로 SBT 옵션을 꽤 많이 사용하는 경우 SBT 옵션을 추가하는 것이 더 좋습니다. source ~/.bash_profile
변경할 때마다 할 필요가 없습니다.SBT_OPTS
If running sbt from PowerShell, set the SBT_OPTs
environment variable, like so:
$env:SBT_OPTS="-Xms512M -Xmx1024M -Xss2M -XX:MaxMetaspaceSize=1024M"
Then run:
sbt
For SBT version 1.0.4 on Windows the default JVM settings come from sbt\conf\sbtconfig.txt
file. Simply edit the values here. Change -Xmx512M
to -Xmx2048M
.
This is not the only source of JVM options for SBT. Others can be found by inspecting sbt.bat
. A simple way to diagnose, where do the settings come from, is by commenting out this line in batch file: @echo off
.
A quick way to do it is with a .jvmopts
file in the root of your project (from the Lagom Framework documentation):
$ cat .jvmopts
-Xms512M
-Xmx4096M
-Xss2M
-XX:MaxMetaspaceSize=1024M
In my case, the configuration of my service was overwriting the environment variable SBT_OPTS
and JAVA_OPTS
. I was able to set the limits by setting in my build.sbt
the following:
javaOptions in Universal ++= Seq(
"-J-Xms1g",
"-J-Xmx2g")
Reference: https://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize.html
참고URL : https://stackoverflow.com/questions/15280839/how-to-set-heap-size-for-sbt
'development' 카테고리의 다른 글
화면 중앙에 토스트를 표시하는 방법 (0) | 2020.10.06 |
---|---|
postgres 기본 시간대 (0) | 2020.10.06 |
C ++ 11을 사용하는 중복 코드 (0) | 2020.10.06 |
"margin : 0 auto;"사용 (0) | 2020.10.06 |
배열을 벡터로 변환하는 가장 간단한 방법은 무엇입니까? (0) | 2020.10.06 |