Skip to content

Commit 838fc92

Browse files
committed
CLOUD-3270 - There is no environment variable to configure the initial metaspace size
1 parent 50b2494 commit 838fc92

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

jboss/container/java/jvm/api/README.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The following environment variables are used to configure the functionality prov
3030
|GC_ADAPTIVE_SIZE_POLICY_WEIGHT |The weighting given to the current GC time versus previous GC times. |90
3131
|GC_CONTAINER_OPTIONS |specify Java GC to use. The value of this variable should contain the necessary JRE command-line options to specify the required GC, which will override the default of `-XX:+UseParallelOldGC`. |-XX:+UseG1GC
3232
|GC_MAX_HEAP_FREE_RATIO |Maximum percentage of heap free after GC to avoid shrinking. |40
33+
|GC_METASPACE_SIZE |The initial metaspace size. |20
3334
|GC_MAX_METASPACE_SIZE |The maximum metaspace size. |100
3435
|GC_MIN_HEAP_FREE_RATIO |Minimum percentage of heap free after GC to avoid expansion. |20
3536
|GC_TIME_RATIO |Specifies the ratio of the time spent outside the garbage collection (for example, the time spent for application execution) to the time spent in the garbage collection. |4

jboss/container/java/jvm/api/module.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ envs:
4848
- name: GC_ADAPTIVE_SIZE_POLICY_WEIGHT
4949
description: The weighting given to the current GC time versus previous GC times.
5050
example: "90"
51+
- name: GC_METASPACE_SIZE
52+
description: The initial metaspace size.
53+
example: "20"
5154
- name: GC_MAX_METASPACE_SIZE
5255
description: The maximum metaspace size.
5356
example: "100"

jboss/container/java/jvm/bash/artifacts/opt/jboss/container/java/jvm/java-default-options

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,29 @@ gc_config() {
137137
local adaptiveSizePolicyWeight=${GC_ADAPTIVE_SIZE_POLICY_WEIGHT:-90}
138138
local maxMetaspaceSize=${GC_MAX_METASPACE_SIZE:-100}
139139
local gcOptions="${GC_CONTAINER_OPTIONS:--XX:+UseParallelOldGC}"
140+
# for compat reasons we don't set a default value for metaspaceSize
141+
local metaspaceSize
142+
143+
if [ -n "${GC_METASPACE_SIZE}" ]; then
144+
metaspaceSize=${GC_METASPACE_SIZE}
145+
# clamp the max size of metaspaceSize to be <= maxMetaspaceSize
146+
if [ "${metaspaceSize}" -gt "${maxMetaspaceSize}" ]; then
147+
metaspaceSize=${maxMetaspaceSize}
148+
fi
149+
fi
150+
151+
local allOptions="$(jvm_specific_options) "
152+
allOptions+="${gcOptions} "
153+
allOptions+="-XX:MinHeapFreeRatio=${minHeapFreeRatio} "
154+
allOptions+="-XX:MaxHeapFreeRatio=${maxHeapFreeRatio} "
155+
allOptions+="-XX:GCTimeRatio=${timeRatio} "
156+
allOptions+="-XX:AdaptiveSizePolicyWeight=${adaptiveSizePolicyWeight} "
157+
allOptions+="-XX:MaxMetaspaceSize=${maxMetaspaceSize}m "
158+
if [ -n "${metaspaceSize}" ]; then
159+
allOptions+="-XX:MetaspaceSize=${metaspaceSize}m "
160+
fi
140161

141-
echo "$(jvm_specific_options) "\
142-
"${gcOptions} " \
143-
"-XX:MinHeapFreeRatio=${minHeapFreeRatio} "\
144-
"-XX:MaxHeapFreeRatio=${maxHeapFreeRatio} "\
145-
"-XX:GCTimeRatio=${timeRatio} "\
146-
"-XX:AdaptiveSizePolicyWeight=${adaptiveSizePolicyWeight} "\
147-
"-XX:MaxMetaspaceSize=${maxMetaspaceSize}m"
162+
echo "${allOptions}"
148163
}
149164

150165
error_handling() {

0 commit comments

Comments
 (0)