diff --git a/native/josm-latest.jnlp b/native/josm-latest.jnlp
index 2c4522e78ed..3fc4125810b 100644
--- a/native/josm-latest.jnlp
+++ b/native/josm-latest.jnlp
@@ -20,7 +20,7 @@
-
+
diff --git a/native/josm.jnlp b/native/josm.jnlp
index 3e31513c3cc..83bd39b1888 100644
--- a/native/josm.jnlp
+++ b/native/josm.jnlp
@@ -20,7 +20,7 @@
-
+
diff --git a/native/linux/latest/etc/default/josm-latest b/native/linux/latest/etc/default/josm-latest
index dbd556ab657..bb792ca8c7e 100644
--- a/native/linux/latest/etc/default/josm-latest
+++ b/native/linux/latest/etc/default/josm-latest
@@ -2,7 +2,7 @@
# Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm-latest
# Increase usable memory
-#JAVA_OPTS="-Xmx2048m ${JAVA_OPTS}"
+#JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -Xms256m ${JAVA_OPTS}"
# Enable OpenGL pipeline (2D graphic accelerators)
#JAVA_OPTS="-Dsun.java2d.opengl=True ${JAVA_OPTS}"
diff --git a/native/linux/latest/usr/bin/josm-latest b/native/linux/latest/usr/bin/josm-latest
index 6b13e674d0f..401a0dc5a92 100755
--- a/native/linux/latest/usr/bin/josm-latest
+++ b/native/linux/latest/usr/bin/josm-latest
@@ -57,6 +57,12 @@ if [ -f "/etc/default/${JOSM_VERSION}" ]; then
. "/etc/default/${JOSM_VERSION}"
fi
+# If there is more than 8G ram, we can use up to 75% of the memory while still leaving 2G for other things.
+if [ "$(free --mega | grep '^Mem:' | awk '{print $2}')" -gt 8192 ]; then
+ # But don't set anything if JAVA_OPTS is already set.
+ JAVA_OPTS="${JAVA_OPTS:=-XX:MaxRAMPercentage=75.0 -Xms256m}"
+fi
+
JAVA_OPTS="-Djosm.restart=true -Djosm.dir.name=JOSM-latest -Djava.net.useSystemProxies=true $JAVA_OPTS"
if [ -z "${JAVACMD}" ] && [ -n "${ALTERNATIVE_JDK}" ]; then
diff --git a/native/linux/tested/etc/default/josm b/native/linux/tested/etc/default/josm
index b646c4f3e0a..508ac3137fa 100644
--- a/native/linux/tested/etc/default/josm
+++ b/native/linux/tested/etc/default/josm
@@ -2,7 +2,7 @@
# Uncomment the JAVA_OPTS lines to enable their use by /usr/bin/josm
# Increase usable memory
-#JAVA_OPTS="-Xmx2048m ${JAVA_OPTS}"
+#JAVA_OPTS="-XX:MaxRAMPercentage=75.0 -Xms256m ${JAVA_OPTS}"
# Enable OpenGL pipeline (2D graphic accelerators)
#JAVA_OPTS="-Dsun.java2d.opengl=True ${JAVA_OPTS}"
diff --git a/native/linux/tested/usr/bin/josm b/native/linux/tested/usr/bin/josm
index d2e18bac141..3611f3815db 100755
--- a/native/linux/tested/usr/bin/josm
+++ b/native/linux/tested/usr/bin/josm
@@ -57,6 +57,12 @@ if [ -f "/etc/default/${JOSM_VERSION}" ]; then
. "/etc/default/${JOSM_VERSION}"
fi
+# If there is more than 8G ram, we can use up to 75% of the memory while still leaving 2G for other things.
+if [ "$(free --mega | grep '^Mem:' | awk '{print $2}')" -gt 8192 ]; then
+ # But don't set anything if JAVA_OPTS is already set.
+ JAVA_OPTS="${JAVA_OPTS:=-XX:MaxRAMPercentage=75.0 -Xms256m}"
+fi
+
JAVA_OPTS="-Djosm.restart=true -Djava.net.useSystemProxies=true $JAVA_OPTS"
if [ -z "${JAVACMD}" ] && [ -n "${ALTERNATIVE_JDK}" ]; then
diff --git a/native/macosx/macos-jpackage.sh b/native/macosx/macos-jpackage.sh
index 8e45abb56a4..8d36bd96986 100755
--- a/native/macosx/macos-jpackage.sh
+++ b/native/macosx/macos-jpackage.sh
@@ -59,6 +59,8 @@ function do_jpackage() {
"${JAVA_HOME}/bin/jpackage" $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
--main-class org.openstreetmap.josm.gui.MainApplication \
--icon ./native/macosx/JOSM.icns --type app-image --dest app \
+ --java-options "-XX:MaxRAMPercentage=75.0" \
+ --java-options "-Xms256m" \
--java-options "--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web" \
--java-options "--add-exports=java.base/sun.security.action=ALL-UNNAMED" \
--java-options "--add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED" \
diff --git a/native/windows/win-jpackage.sh b/native/windows/win-jpackage.sh
index 5626cedb70a..9632b6f763c 100755
--- a/native/windows/win-jpackage.sh
+++ b/native/windows/win-jpackage.sh
@@ -51,6 +51,8 @@ do
jpackage $JPACKAGEOPTIONS -n "JOSM" --input dist --main-jar josm-custom.jar \
--main-class org.openstreetmap.josm.gui.MainApplication \
--icon ./native/windows/logo.ico --type $type --dest app \
+ --java-options "-XX:MaxRAMPercentage=75.0" \
+ --java-options "-Xms256m" \
--java-options "--add-modules java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web" \
--java-options "--add-exports=java.base/sun.security.action=ALL-UNNAMED" \
--java-options "--add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED" \