How to set heap size for sbt?

前端 未结 10 1169
日久生厌
日久生厌 2020-11-29 17:38

I am using SBT 0.12.0. I have read other answers on stack overflow and followed them, however none of them helps, for example:

  • create ForkRun clas
10条回答
  •  野性不改
    2020-11-29 18:08

    I have found the solution. No matter how you specify JVM heap size, it will never work because SBT executable already has it overridden.

    There is a line in SBT executable which says:

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

    So I edited the file:

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

    Remove the - line.

    Now when you run SBT, it will no longer override your JVM heap size settings. You can specify heap size settings using @Noan's answer.

    Or alternatively:

    sbt -J-Xmx4G -J-Xms4G

提交回复
热议问题