diff --git a/README.md b/README.md index 4b37892e..bfdb475f 100644 --- a/README.md +++ b/README.md @@ -1288,7 +1288,9 @@ The values of all three are passed directly to the JVM and support format/units -e MEMORY=2G -> NOTE: the settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container). +> To let the JVM calculate the heap size from the container declared memory limit, unset `MEMORY` with an empty value, such as `-e MEMORY=""`. + +> The settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container). ### JVM Options diff --git a/scripts/start-finalExec b/scripts/start-finalExec index 60e78d40..1112f104 100755 --- a/scripts/start-finalExec +++ b/scripts/start-finalExec @@ -70,8 +70,8 @@ if [[ ${GUI} = false || ${GUI} = FALSE ]]; then EXTRA_ARGS+=" nogui" fi -# put these prior JVM_OPTS at the end to give any memory settings there higher precedence -log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}" +: "${INIT_MEMORY:=${MEMORY}}" +: "${MAX_MEMORY:=${MEMORY}}" expandedDOpts= if [ -n "$JVM_DD_OPTS" ]; then @@ -157,7 +157,15 @@ if isTrue "${DEBUG_MEMORY}"; then free -m fi -JVM_OPTS="-Xms${INIT_MEMORY} -Xmx${MAX_MEMORY} ${JVM_OPTS}" +if [[ ${INIT_MEMORY} || ${MAX_MEMORY} ]]; then + log "Setting initial memory to ${INIT_MEMORY:=${MEMORY}} and max to ${MAX_MEMORY:=${MEMORY}}" + if [[ ${INIT_MEMORY} ]]; then + JVM_OPTS="-Xms${INIT_MEMORY} ${JVM_OPTS}" + fi + if [[ ${MAX_MEMORY} ]]; then + JVM_OPTS="-Xmx${MAX_MEMORY} ${JVM_OPTS}" + fi +fi function copyFilesForCurseForge() { # copy player modification files unconditionally since their @@ -197,11 +205,11 @@ elif [[ ${TYPE} == "CURSEFORGE" ]]; then cat > "${FTB_DIR}/settings-local.sh" <