Skip to content

IBM Java enforces default max heap size on startup, when larger -Xms is specified #14386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gjdeval opened this issue Jan 27, 2022 · 3 comments
Closed

Comments

@gjdeval
Copy link

gjdeval commented Jan 27, 2022

If the user specifies an -Xms value that is larger than the default max heap size, and does not specify -Xmx, the JVM fails to start, because it enforces the default -Xmx. Note also that the error message IBM Java gives in this scenario is somewhat cryptic:
JVMJ9GC020E -Xms too large for heap
This does not tell the user what the real problem is (default -Xmx), or how to fix it.

In this situation, it would be more user-friendly for the JVM to start, with -Xmx set equal to the user-specified -Xms, since the user clearly wants a heap at least as big as the -Xms value. (this assumes the system free memory accommodates the specified -Xms)

That is how Oracle Java handles the situation, by the way: If the user-specified -Xms is larger than the default MaxHeapSize, the JVM starts with MaxHeapSize set equal to the user-specified -Xms value.

@pshipton
Copy link
Member

@dmitripivkine

@dmitripivkine dmitripivkine added this to the Backlog milestone Jan 28, 2022
@imkabir
Copy link
Contributor

imkabir commented Apr 3, 2025

@joransiu and I had been discussing about a critical case when we came across this issue.

Recently we had a critical customer issue on Z/OS where:

a) Customer had a small available memory (less than 1g)
b) They had only Xms set at 512m
c) JVM startup failed with "JVMJ9GC020E -Xms too large for heap"

The error message was not very helpful. Also, when Xms is specified without an Xmx, if Xmx by default is matched with Xms, it would be more meaningful and intuitive to the user.

Our suggestions are:

  1. Consider matching Oracle's behaivour - if -Xms is specified, consider requesting at least that much -Xmx even if it is not specified.
  2. Update our error message to advise what the user should do. Something like: "-Xms too large for heap. Please adjust its value relative to the -Xmx settings. Use -verbose:sizes to display the current settings."

These would help user to fix the problem by themselves.

@dmitripivkine fyi.

dmitripivkine added a commit to dmitripivkine/openj9 that referenced this issue Apr 8, 2025
In the case if maximum heap size is not specified and taken by default
and initial heap size is specified and initial value is larger than
default maximum increase maximum heap size to match initial size.

Related eclipse-openj9#14386

Signed-off-by: Dmitri Pivkine <[email protected]>
dmitripivkine added a commit to dmitripivkine/openj9 that referenced this issue Apr 9, 2025
In the case if maximum heap size is not specified and taken by default
and initial heap size is specified and initial value is larger than
default maximum increase maximum heap size to match initial size.

Related eclipse-openj9#14386

Signed-off-by: Dmitri Pivkine <[email protected]>
dmitripivkine added a commit to dmitripivkine/openj9 that referenced this issue Apr 9, 2025
In the case if maximum heap size is not specified and taken by default
and initial heap size is specified and initial value is larger than
default maximum increase maximum heap size to match initial size.

Related eclipse-openj9#14386

Signed-off-by: Dmitri Pivkine <[email protected]>
dmitripivkine added a commit to dmitripivkine/openj9 that referenced this issue Apr 9, 2025
In the case if maximum heap size is not specified and taken by default
and initial heap size is specified and initial value is larger than
default maximum increase maximum heap size to match initial size.

Related eclipse-openj9#14386

Signed-off-by: Dmitri Pivkine <[email protected]>
@dmitripivkine
Copy link
Contributor

Resolved with #21602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants