From c044ed36af1ebb969b1b8d4a3ef80895ec681921 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 9 Apr 2026 19:34:11 +0500 Subject: [PATCH 1/3] feat: allow disabling low RAM warning Signed-off-by: Octol1ttle --- launcher/Application.cpp | 6 + launcher/minecraft/MinecraftInstance.cpp | 1 + .../launch/EnsureAvailableMemory.cpp | 29 +- launcher/ui/widgets/JavaSettingsWidget.cpp | 3 + launcher/ui/widgets/JavaSettingsWidget.ui | 316 +++++++++--------- 5 files changed, 189 insertions(+), 166 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 7af39b55e..e7acc9038 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -736,6 +736,12 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting({ "MaxMemAlloc", "MaxMemoryAlloc" }, SysInfo::defaultMaxJvmMem()); m_settings->registerSetting("PermGen", 128); + // https://github.com/PrismLauncher/PrismLauncher/issues/5305 + // arm64 Macs have configurations with very little physical memory, but the OS can compensate by compressing and swapping + // According to user reports, this is not noticeable under normal usage due to fast storage speeds + const bool lowMemWarningDefault = !(SysInfo::currentSystem() == "osx" && SysInfo::useQTForArch() == "arm64"); + m_settings->registerSetting("LowMemWarning", lowMemWarningDefault); + // Java Settings m_settings->registerSetting("JavaPath", ""); m_settings->registerSetting("JavaSignature", ""); diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 2848f1e99..e8fc642fa 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -209,6 +209,7 @@ void MinecraftInstance::loadSpecificSettings() m_settings->registerOverride(global_settings->getSetting("MinMemAlloc"), memorySetting); m_settings->registerOverride(global_settings->getSetting("MaxMemAlloc"), memorySetting); m_settings->registerOverride(global_settings->getSetting("PermGen"), memorySetting); + m_settings->registerOverride(global_settings->getSetting("LowMemWarning"), memorySetting); // Native library workarounds auto nativeLibraryWorkaroundsOverride = m_settings->registerSetting("OverrideNativeWorkarounds", false); diff --git a/launcher/minecraft/launch/EnsureAvailableMemory.cpp b/launcher/minecraft/launch/EnsureAvailableMemory.cpp index 8a436a6f6..ae0ffe1ef 100644 --- a/launcher/minecraft/launch/EnsureAvailableMemory.cpp +++ b/launcher/minecraft/launch/EnsureAvailableMemory.cpp @@ -31,20 +31,25 @@ void EnsureAvailableMemory::executeTask() const uint64_t required = std::max(min, max); if (required > available) { - auto* dialog = CustomMessageBox::selectable( - nullptr, tr("Not enough RAM"), - tr("There is not enough RAM available to launch this instance with the current memory settings.\n\n" - "Required: %1 MiB\nAvailable: %2 MiB\n\n" - "Continue anyway? This may cause slowdowns in the game and your system.") - .arg(required) - .arg(available), - QMessageBox::Icon::Warning, QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, - QMessageBox::StandardButton::No); - const auto response = dialog->exec(); - dialog->deleteLater(); + bool shouldAbort = false; + + if (m_instance->settings()->get("LowMemWarning").toBool()) { + auto* dialog = CustomMessageBox::selectable( + nullptr, tr("Not enough RAM"), + tr("There is not enough RAM available to launch this instance with the current memory settings.\n\n" + "Required: %1 MiB\nAvailable: %2 MiB\n\n" + "Continue anyway? This may cause slowdowns in the game and your system.") + .arg(required) + .arg(available), + QMessageBox::Icon::Warning, QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, + QMessageBox::StandardButton::No); + + shouldAbort = dialog->exec() == QMessageBox::No; + dialog->deleteLater(); + } const auto message = tr("Not enough RAM available to launch this instance"); - if (response == QMessageBox::No) { + if (shouldAbort) { emit logLine(message, MessageLevel::Fatal); emitFailed(message); return; diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp index 4e74c610f..e13c847d0 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.cpp +++ b/launcher/ui/widgets/JavaSettingsWidget.cpp @@ -151,6 +151,7 @@ void JavaSettingsWidget::loadSettings() m_ui->maxMemSpinBox->setValue(min); } m_ui->permGenSpinBox->setValue(settings->get("PermGen").toInt()); + m_ui->lowMemWarningCheckBox->setChecked(settings->get("LowMemWarning").toBool()); // Java arguments m_ui->javaArgumentsGroupBox->setChecked(m_instance == nullptr || settings->get("OverrideJavaArgs").toBool()); @@ -205,10 +206,12 @@ void JavaSettingsWidget::saveSettings() settings->set("MaxMemAlloc", min); } settings->set("PermGen", m_ui->permGenSpinBox->value()); + settings->set("LowMemWarning", m_ui->lowMemWarningCheckBox->isChecked()); } else { settings->reset("MinMemAlloc"); settings->reset("MaxMemAlloc"); settings->reset("PermGen"); + settings->reset("LowMemWarning"); } // Java arguments diff --git a/launcher/ui/widgets/JavaSettingsWidget.ui b/launcher/ui/widgets/JavaSettingsWidget.ui index 46f714b76..14638cf4e 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.ui +++ b/launcher/ui/widgets/JavaSettingsWidget.ui @@ -55,7 +55,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -86,7 +86,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -101,10 +101,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -160,10 +160,10 @@ - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -190,156 +190,166 @@ false - - - + + + + + + + M&inimum Memory Usage: + + + minMemSpinBox + + + + + + + + + + 0 + 0 + + + + The amount of memory Minecraft is started with. + + + MiB + + + 8 + + + 1048576 + + + 128 + + + 256 + + + + + + + (-Xms) + + + + + + + + + Ma&ximum Memory Usage: + + + maxMemSpinBox + + + + + + + + + + 0 + 0 + + + + The maximum amount of memory Minecraft is allowed to use. + + + MiB + + + 8 + + + 1048576 + + + 128 + + + 1024 + + + + + + + (-Xmx) + + + + + + + + + &PermGen Size: + + + permGenSpinBox + + + + + + + + + + 0 + 0 + + + + The amount of memory available to store loaded Java classes. + + + MiB + + + 4 + + + 1048576 + + + 8 + + + 64 + + + + + + + (-XX:PermSize) + + + + + + + + + - (-XX:PermSize) + Warn when there is not enough memory available - - - - - 0 - 0 - - - - The amount of memory available to store loaded Java classes. - - - MiB - - - 4 - - - 1048576 - - - 8 - - - 64 - - - - - - - - 0 - 0 - - - - The maximum amount of memory Minecraft is allowed to use. - - - MiB - - - 8 - - - 1048576 - - - 128 - - - 1024 - - - - - - - (-Xmx) - - - - - - - - 0 - 0 - - - - The amount of memory Minecraft is started with. - - - MiB - - - 8 - - - 1048576 - - - 128 - - - 256 - - - - - - - &PermGen Size: - - - permGenSpinBox - - - - - - - (-Xms) - - - - - - - Ma&ximum Memory Usage: - - - maxMemSpinBox - - - - - - - M&inimum Memory Usage: - - - minMemSpinBox - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - + Memory Notice @@ -382,9 +392,7 @@ autodownloadJavaCheckBox javaTestBtn javaDownloadBtn - minMemSpinBox maxMemSpinBox - permGenSpinBox jvmArgsTextBox From 658a1391f8fbcf7b51ffc741d393728768b4a5b1 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Thu, 9 Apr 2026 22:35:32 +0500 Subject: [PATCH 2/3] change(EnsureAvailableMemory): add lenience Signed-off-by: Octol1ttle --- launcher/minecraft/launch/EnsureAvailableMemory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/launch/EnsureAvailableMemory.cpp b/launcher/minecraft/launch/EnsureAvailableMemory.cpp index ae0ffe1ef..a0e156770 100644 --- a/launcher/minecraft/launch/EnsureAvailableMemory.cpp +++ b/launcher/minecraft/launch/EnsureAvailableMemory.cpp @@ -30,7 +30,7 @@ void EnsureAvailableMemory::executeTask() const uint64_t max = m_instance->settings()->get("MaxMemAlloc").toUInt(); const uint64_t required = std::max(min, max); - if (required > available) { + if (static_cast(required) * 0.9 > static_cast(available)) { bool shouldAbort = false; if (m_instance->settings()->get("LowMemWarning").toBool()) { From 4b3aedd5d0567b57856453c96250637cf1495f67 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Fri, 10 Apr 2026 11:53:37 +0500 Subject: [PATCH 3/3] Change LowMemWarning default to always enabled Signed-off-by: Octol1ttle --- launcher/Application.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index e7acc9038..115b6489c 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -735,12 +735,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv) m_settings->registerSetting({ "MinMemAlloc", "MinMemoryAlloc" }, 512); m_settings->registerSetting({ "MaxMemAlloc", "MaxMemoryAlloc" }, SysInfo::defaultMaxJvmMem()); m_settings->registerSetting("PermGen", 128); - - // https://github.com/PrismLauncher/PrismLauncher/issues/5305 - // arm64 Macs have configurations with very little physical memory, but the OS can compensate by compressing and swapping - // According to user reports, this is not noticeable under normal usage due to fast storage speeds - const bool lowMemWarningDefault = !(SysInfo::currentSystem() == "osx" && SysInfo::useQTForArch() == "arm64"); - m_settings->registerSetting("LowMemWarning", lowMemWarningDefault); + m_settings->registerSetting("LowMemWarning", true); // Java Settings m_settings->registerSetting("JavaPath", "");