¿Cómo configurar el tamaño del montón para sbt?


Estoy usando SBT 0.12.0. He leído otras respuestas en stack overflow y las he seguido, sin embargo ninguna de ellas ayuda, por ejemplo:

  • create ForkRun class - No he observado ningún proceso bifurcado durante mi uso de sbt
  • set variable de entorno JAVA_OPTS - está establecida pero la línea de comandos de proceso de sbt no parece usarla en absoluto.
  • sbt -J-Xmx2G añade el parámetro a la línea de comandos del proceso sbt, sin embargo, el antiguo valor -Xmx1536m es utilizado por sbt en lugar del parámetro.

¿Me estoy perdiendo algo? ¿Cómo puedo configurar el tamaño del montón para sbt 0.12, al hacer ambas pruebas y run?

 71
Author: spydon, 2013-03-08

8 answers

Necesitas SBT_OPTS, esto es lo que uso en mi .bash_profile:

export SBT_OPTS="-Xmx1536M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M  -Duser.timezone=GMT"

ACTUALIZACIÓN: Para obtener su espacio de montón 2G puede usar esto:

export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M  -Duser.timezone=GMT"

NOTA: SBT DEBE SER LA ÚLTIMA VERSIÓN

Las versiones anteriores de sbt contienen errores que anulan estas configuraciones, use brew upgrade sbt para la última sbt para Mac (suponiendo que se instale brew) (IDK para Linux). https://github.com/sbt/sbt/issues/2945#issuecomment-277490848

 84
Author: Noah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-05 12:05:47

A partir de marzo de 2015, si está utilizando sbt en OSX con Homebrew entonces debe editar el archivo /usr/local/etc/sbtopts

Por ejemplo

# set memory options
#
#-mem   <integer>
-mem 2048
 54
Author: Synesso,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-16 00:44:44

"sbt-mem 23000 run" funciona para mí.

 34
Author: GBY,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-02 20:16:17

He encontrado la solución. No importa cómo especifique el tamaño del montón de JVM, nunca funcionará porque el ejecutable SBT ya lo ha anulado.

Hay una línea en el ejecutable SBT que dice:

. /usr/share/sbt/sbt-launch-lib.bash

Así que edité el archivo:

  # 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[@]}"

Elimine la línea -.

Ahora, cuando ejecute SBT, ya no anulará su configuración de tamaño de montón de JVM. Puede especificar la configuración del tamaño del montón usando la respuesta de @Noan.

O alternativamente:

sbt -J-Xmx4G -J-Xms4G

 19
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-07 23:53:53

En Windows, para sbt 0.13.9.2, debe establecer JAVA_OPTS a las opciones de jvm que desee.

> set JAVA_OPTS=-Xmx1G
> sbt assembly

El script sbt.bat carga sus valores predeterminados desde conf\sbtconfig.txt en CFG_OPTS pero usará JAVA_OPTS en su lugar si se establece.

Extractos relevantes de 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!
)

. . . (saltar) . . .

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 %*
 15
Author: Choy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-20 15:53:30

Estaba buscando resolver un problema como este en Mac OS X con una instalación homebrew de SBT. Si instalaste SBT a través de homebrew, estás en el claro ya que el archivo /usr/local/bin/sbt se parece a

#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
exec java -Xmx512M ${SBT_OPTS} -jar /usr/local/Cellar/sbt/0.12.3/libexec/sbt-launch.jar "$@"

Esto significa que cualquier configuración que ponga en SBT_OPTS se mantendrá (su-Xmx tendrá prioridad). Además, la primera línea del script ejecutará cualquier comando en ~/.sbtconfig si existe, por lo que puede ser un mejor lugar para poner sus opciones SBT si está jugando con ellas un poco. Usted no tendrá que source ~/.bash_profile cada vez que realice un cambio en SBT_OPTS

 11
Author: Adrian Rodriguez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-07-02 23:00:22

Si ejecuta sbt desde PowerShell, establezca la variable de entorno SBT_OPTs de la siguiente manera:

$env:SBT_OPTS="-Xms512M -Xmx1024M -Xss2M -XX:MaxMetaspaceSize=1024M"

Luego ejecute:

sbt
 4
Author: sungiant,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-16 11:53:33

Para SBT versión 1.0.4 en Windows la configuración predeterminada JVM proviene de sbt\conf\sbtconfig.txt archivo. Simplemente edite los valores aquí. Cambiar -Xmx512M por -Xmx2048M.

Esta no es la única fuente de opciones JVM para SBT. Otros se pueden encontrar inspeccionando sbt.bat. Una forma sencilla de diagnosticar, de dónde vienen los ajustes, es comentando esta línea en el archivo por lotes: @echo off.

 2
Author: Jarekczek,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-03 18:04:31