Repository navigation
Conversation
Forward --xms-equals-xmx to the memory calculator when JBP_CONFIG_<JRE>_JRE sets memory_calculator.xms_equals_xmx: true. Disabled by default; the flag is only passed when enabled, because calculator releases before the one that adds it exit with "unknown flag". Refs cloudfoundry#1377
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The packaged memory calculator 4.2.0 rejects --xms-equals-xmx, causing startup to fail before the JVM launches when the option is enabled.
1 open issue
What changed in this PR
Adds an opt-in initial-heap setting to the shared JRE memory calculator integration, addressing the equal-heap use case from #1377 while leaving default behavior unchanged.
Changes:
- Reads
memory_calculator.xms_equals_xmxfrom JRE-specific configuration and forwards--xms-equals-xmxwhen enabled. - Adds unit and Spring Boot integration tests for enabled and default behavior.
- Documents the option, explicit
-Xmsprecedence, and memory tradeoffs; corrects the sample calculator output.
| File | Description |
|---|---|
src/java/jres/memory_calculator.go |
Loads the option, forwards the flag, and logs enablement. |
src/java/jres/memory_calculator_issues_test.go |
Tests opt-in forwarding, defaults, and configuration compatibility. |
src/integration/spring_boot_test.go |
Checks JVM heap arguments with and without the option. |
docs/jre-open_jdk_jre.md |
Explains initial-heap configuration and operational tradeoffs. |
docs/IMPLEMENTING_JRES.md |
Documents the shared option and corrects sample output. |
Review effort: Balanced
| } | ||
|
|
||
| if m.xmsEqualsXmx { | ||
| args = append(args, "--xms-equals-xmx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds an opt-in
xms_equals_xmxoption to thememory_calculatormapping, for exampleJBP_CONFIG_OPEN_JDK_JRE: '{memory_calculator: {xms_equals_xmx: true}}'. It makes the memory calculator set-Xmsequal to-Xmxthrough the new--xms-equals-xmxflag from cloudfoundry/java-buildpack-memory-calculator#55.Disabled by default, and the flag is only passed when enabled. It works for every JRE through its own
JBP_CONFIG_*_JREvariable. There is noMEMORY_CALCULATOR_*env var for it, same asclass_count. Happy to add one if you prefer.This stays a draft until a calculator release with the flag is in
manifest.yml. The released 4.2.0 rejects the flag (unknown flag: --xms-equals-xmx, exit 2) and the start command stops there, so an app that enables the option would not start. Apps that do not set the option are not affected.What I checked:
true,false, another JRE, combined with other settings, no unknown-field warning). Two mutants (flag never passed, flag always passed) are caught.main:-Xmxand-Xmsequal; explicit-Xmsis respected;-Xmslarger than-Xmxfails with the calculator error./input-arguments: with the option,-Xmsequals-Xmx; by default, no-Xms. Both pass with a calculator built frommain. The first fails against the released 4.2.0, and the container log showsunknown flag: --xms-equals-xmx.Docs: new "Initial Heap" section in
docs/jre-open_jdk_jre.md. Indocs/IMPLEMENTING_JRES.mdI added the option and removed a wrong-Xms512Mfrom the sample output, because the calculator did not emit one before.Refs #1377