Skip to content

Bump default JVM heap and add OOM diagnostics#2044

Open
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:jvm-defaults-oom-diagnostics
Open

Bump default JVM heap and add OOM diagnostics#2044
jbonofre wants to merge 1 commit into
apache:mainfrom
jbonofre:jvm-defaults-oom-diagnostics

Conversation

@jbonofre
Copy link
Copy Markdown
Member

@jbonofre jbonofre commented May 26, 2026

  • Raise the shipped default heap from -Xms64M -Xmx1G to -Xms512M -Xmx2G in assembly/src/release/bin/setenv. The previous default is undersized for a production broker; the new value is still modest and remains overridable via ACTIVEMQ_OPTS_MEMORY.
  • Add a new ACTIVEMQ_OOM_OPTS variable defaulting to -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$ACTIVEMQ_DATA -XX:+ExitOnOutOfMemoryError so that an OutOfMemoryError produces a heap dump under the broker data directory and the JVM terminates rather than continuing in a degraded state.
  • Mirror the same ACTIVEMQ_OOM_OPTS fallback inside assembly/src/release/bin/activemq so the diagnostics still apply if setenv is absent.

Both new variables remain overridable from the environment or from any of the higher-priority configuration files (/etc/default/activemq, ~/.activemqrc, bin/setenv).

Raise the shipped default heap from -Xms64M/-Xmx1G to -Xms512M/-Xmx2G
which is more representative of a production broker workload while
still leaving headroom on small hosts (override via ACTIVEMQ_OPTS_MEMORY).

Add ACTIVEMQ_OOM_OPTS with -XX:+HeapDumpOnOutOfMemoryError,
-XX:HeapDumpPath=$ACTIVEMQ_DATA and -XX:+ExitOnOutOfMemoryError so
that an OutOfMemoryError produces a heap dump for postmortem and the
JVM terminates instead of lingering in a degraded state. The same
defaults are wired into the fallback in bin/activemq for the case
where setenv is missing.
@jbonofre jbonofre requested review from cshannon and mattrpav May 26, 2026 15:58
@jbonofre
Copy link
Copy Markdown
Member Author

@cshannon I propose to update the default configuration like this.

@cshannon
Copy link
Copy Markdown
Contributor

Hmm, I think this might need more discussion. I think the 2GB default is good but I don't know about the OOM heap dump as that will cause unexpected output to a file system for users. I think that needs to be configurable on set up maybe. We could bring it up for discussion on the dev list.

@jbonofre
Copy link
Copy Markdown
Member Author

@cshannon yes, I can add a optional flag to setup OOM. I'm just sharing my experience: I have to ask more of the ActiveMQ users to enable it it to investigate 😄 So having a way to enable it by default would be good (or at least documented).

@cshannon
Copy link
Copy Markdown
Contributor

@cshannon yes, I can add a optional flag to setup OOM. I'm just sharing my experience: I have to ask more of the ActiveMQ users to enable it it to investigate 😄 So having a way to enable it by default would be good (or at least documented).

That sounds good, I personally set that flag myself so I am fine with it but I figure someone might not want the extra output.
It can be an issue if the broker gets into an OOM restart loop and has the potential to fill up a partition so users should be aware it's on or at least opt into it.

@mattrpav
Copy link
Copy Markdown
Contributor

+1 to have a preconfigured but commented out set of options. Having it on by default can quickly lead to disk space usage issues -- there is also a 'where to write the files' problem

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants