docker-minecraft-server
docker-minecraft-server copied to clipboard
Provide a clearer way to request JVM to derive memory limit percentages
Enhancement Type
Improve an existing feature
Describe the enhancement
As observed in #1512 , the unsetting of MEMORY with an empty string is an awkward and brittle way of saying "I would like the JVM to derive heap limits from the host/container".
I would like to instead introduce the new variables:
MEMORY_PCTMAX_MEMORY_PCT, defaults toMEMORY_PCTMIN_MEMORY_PCT, defaults toMEMORY_PCT
That will indicate MEMORY and co be ignored, but also add the JVM args, such as -XX:MaxRAMPercentage=75
@itzg This is easy to add in start-finalExec, but the real question is how do you want this to be triggered? Do we want to replace MEMORY with MEMORY_PCT? I can't imagine as it is probably widely in use. 🤔 Really this is more in how we'd want to handle memory_pct vs min and max. Thoughts?
if [ ! "${MEMORY}" ]; then
MIN_MEMORY_PCT=$([ "$MIN_MEMORY_PCT" ] && echo "$MIN_MEMORY_PCT" || echo "$MEMORY_PCT")
MAX_MEMORY_PCT=$([ "$MAX_MEMORY_PCT" ] && echo "$MAX_MEMORY_PCT" || echo "$MEMORY_PCT")
JVM_XX_OPTS="${JVM_XX_OPTS}
-XX:MinRAMPercentage=${MIN_MEMORY_PCT}
-XX:MaxRAMPercentage=${MAX_MEMORY_PCT}
"
fi
To reword what I meant in the description: if any of the "PCT" variables are set, then the MEMORY variables are ignored. Otherwise, MEMORY variables remain working as always.
I was just expecting the usual fallback variable mechanism like
: "${MIN_MEMORY_PCT:=${MEMORY_PCT:-25}}"
and then say 95 for the final fallback for max pct.