From 7155e2c81be325df3929920e43a151062221842e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JB=20Onofr=C3=A9?= Date: Tue, 26 May 2026 17:56:43 +0200 Subject: [PATCH] Bump default JVM heap and add OOM diagnostics 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. --- assembly/src/release/bin/activemq | 6 +++++- assembly/src/release/bin/setenv | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/assembly/src/release/bin/activemq b/assembly/src/release/bin/activemq index 9aa1eeeeb16..bc167975a30 100755 --- a/assembly/src/release/bin/activemq +++ b/assembly/src/release/bin/activemq @@ -198,8 +198,12 @@ if [ "$CONFIG_LOAD" != "yes" ];then echo fi +if [ -z "$ACTIVEMQ_OOM_OPTS" ] ; then + ACTIVEMQ_OOM_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=\"$ACTIVEMQ_DATA\" -XX:+ExitOnOutOfMemoryError" +fi + if [ -z "$ACTIVEMQ_OPTS" ] ; then - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=\"$ACTIVEMQ_CONF\"/login.config" + ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY $ACTIVEMQ_OOM_OPTS -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=\"$ACTIVEMQ_CONF\"/login.config" fi diff --git a/assembly/src/release/bin/setenv b/assembly/src/release/bin/setenv index 799b640bc45..6c8ccadd470 100644 --- a/assembly/src/release/bin/setenv +++ b/assembly/src/release/bin/setenv @@ -31,10 +31,17 @@ # Set jvm memory configuration (minimal/maximum amount of memory) if [ -z "$ACTIVEMQ_OPTS_MEMORY" ] ; then - ACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx1G" + ACTIVEMQ_OPTS_MEMORY="-Xms512M -Xmx2G" fi + +# Dump the heap and terminate the JVM on OutOfMemoryError so the failure is +# captured for postmortem and the broker is not left running in a degraded state. +if [ -z "$ACTIVEMQ_OOM_OPTS" ] ; then + ACTIVEMQ_OOM_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$ACTIVEMQ_DATA -XX:+ExitOnOutOfMemoryError" +fi + if [ -z "$ACTIVEMQ_OPTS" ] ; then - ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" + ACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY $ACTIVEMQ_OOM_OPTS -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config" fi if [ -z "$ACTIVEMQ_OUT" ]; then