Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Added MAX_HEAP_SIZE_MB to avoid a calculated size being too large #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ If the default command (java) is used, then the entry point sources the [setup-e
|`GAE_MEMORY_MB` | Available memory | size | Set by GAE or `/proc/meminfo`-400M |
|`HEAP_SIZE_RATIO` | Memory for the heap | percent | 80 |
|`HEAP_SIZE_MB` | Available heap | size | `${HEAP_SIZE_RATIO}`% of `${GAE_MEMORY_MB}` |
|`MAX_HEAP_SIZE_MB` | Max calculated heap | size | 20 * 1024 |
|`JAVA_HEAP_OPTS` | JVM heap args | JVM args | `-Xms${HEAP_SIZE_MB}M -Xmx${HEAP_SIZE_MB}M` |
|`JAVA_GC_OPTS` | JVM GC args | JVM args | `-XX:+UseG1GC` plus configuration |
|`JAVA_USER_OPTS` | JVM other args | JVM args | |
Expand Down
8 changes: 7 additions & 1 deletion openjdk-common/src/main/docker/setup-env.d/30-java-env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ GetAvailableMemory () {
export JAVA_TMP_OPTS=${JAVA_TMP_OPTS:-$( if [[ -z ${TMPDIR} ]]; then echo ""; else echo "-Djava.io.tmpdir=$TMPDIR"; fi)}
export GAE_MEMORY_MB=${GAE_MEMORY_MB:-$(GetAvailableMemory)}
export HEAP_SIZE_RATIO=${HEAP_SIZE_RATIO:-"80"}
export HEAP_SIZE_MB=${HEAP_SIZE_MB:-$(expr ${GAE_MEMORY_MB} \* ${HEAP_SIZE_RATIO} / 100)}
if [ -z $HEAP_SIZE_MB ]; then
HEAP_SIZE_MB=$(expr ${GAE_MEMORY_MB} \* ${HEAP_SIZE_RATIO} / 100)
MAX_HEAP_SIZE_MB=${MAX_HEAP_SIZE_MB:-$(expr 20 \* 1024)}
if [ $HEAP_SIZE_MB -gt $MAX_HEAP_SIZE_MB ]; then
export HEAP_SIZE_MB=$MAX_HEAP_SIZE_MB
fi
fi
export JAVA_HEAP_OPTS=${JAVA_HEAP_OPTS:-"-Xms${HEAP_SIZE_MB}M -Xmx${HEAP_SIZE_MB}M"}
export JAVA_GC_OPTS=${JAVA_GC_OPTS:-"-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+PrintCommandLineFlags"}
export JAVA_OPTS=${JAVA_OPTS:--showversion ${JAVA_TMP_OPTS} ${DBG_AGENT} ${PROFILER_AGENT} ${JAVA_HEAP_OPTS} ${JAVA_GC_OPTS} ${JAVA_USER_OPTS}}