feat: validate maximum memory allocation
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
46a8e18841
commit
5ee4fb3522
@ -58,9 +58,8 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tabWidget->tabBar()->hide();
|
ui->tabWidget->tabBar()->hide();
|
||||||
|
|
||||||
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
|
||||||
ui->maxMemSpinBox->setMaximum(sysMiB);
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaPage::~JavaPage()
|
JavaPage::~JavaPage()
|
||||||
@ -177,6 +176,11 @@ void JavaPage::on_javaTestBtn_clicked()
|
|||||||
checker->run();
|
checker->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaPage::on_maxMemSpinBox_valueChanged(int i)
|
||||||
|
{
|
||||||
|
updateThresholds();
|
||||||
|
}
|
||||||
|
|
||||||
void JavaPage::checkerFinished()
|
void JavaPage::checkerFinished()
|
||||||
{
|
{
|
||||||
checker.reset();
|
checker.reset();
|
||||||
@ -186,3 +190,20 @@ void JavaPage::retranslate()
|
|||||||
{
|
{
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaPage::updateThresholds()
|
||||||
|
{
|
||||||
|
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
||||||
|
unsigned int maxMem = ui->maxMemSpinBox->value();
|
||||||
|
|
||||||
|
if (maxMem >= sysMiB) {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"✘");
|
||||||
|
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
|
||||||
|
} else if (maxMem > (sysMiB * 0.9)) {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"⚠");
|
||||||
|
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
|
||||||
|
} else {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"✔");
|
||||||
|
ui->labelMaxMemIcon->setToolTip("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -76,6 +76,8 @@ public:
|
|||||||
bool apply() override;
|
bool apply() override;
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
|
void updateThresholds();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
@ -85,6 +87,7 @@ slots:
|
|||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
void on_javaTestBtn_clicked();
|
void on_javaTestBtn_clicked();
|
||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
void on_maxMemSpinBox_valueChanged(int i);
|
||||||
void checkerFinished();
|
void checkerFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -44,8 +44,8 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Memory</string>
|
<string>Memory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
|
||||||
<item row="1" column="1">
|
<item row="1" column="2">
|
||||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
<widget class="QSpinBox" name="maxMemSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
||||||
@ -67,27 +67,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelMinMem">
|
<widget class="QLabel" name="labelPermGen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Minimum memory allocation:</string>
|
<string notr="true">&PermGen:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>minMemSpinBox</cstring>
|
<cstring>permGenSpinBox</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="labelMaxMem">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ma&ximum memory allocation:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>maxMemSpinBox</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QSpinBox" name="minMemSpinBox">
|
<widget class="QSpinBox" name="minMemSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory Minecraft is started with.</string>
|
<string>The amount of memory Minecraft is started with.</string>
|
||||||
@ -109,17 +99,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelPermGen">
|
<widget class="QLabel" name="labelMaxMem">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">&PermGen:</string>
|
<string>Ma&ximum memory allocation:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy">
|
<property name="buddy">
|
||||||
<cstring>permGenSpinBox</cstring>
|
<cstring>maxMemSpinBox</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelMinMem">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Minimum memory allocation:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>minMemSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
<widget class="QSpinBox" name="permGenSpinBox">
|
<widget class="QSpinBox" name="permGenSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory available to store loaded Java classes.</string>
|
<string>The amount of memory available to store loaded Java classes.</string>
|
||||||
@ -141,6 +141,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="labelMaxMemIcon">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>maxMemSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -59,12 +59,12 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
m_settings = inst->settings();
|
m_settings = inst->settings();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
auto sysMB = Sys::getSystemRam() / Sys::mebibyte;
|
|
||||||
ui->maxMemSpinBox->setMaximum(sysMB);
|
|
||||||
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
||||||
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
||||||
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceSettingsPage::shouldDisplay() const
|
bool InstanceSettingsPage::shouldDisplay() const
|
||||||
@ -437,6 +437,11 @@ void InstanceSettingsPage::on_javaTestBtn_clicked()
|
|||||||
checker->run();
|
checker->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i)
|
||||||
|
{
|
||||||
|
updateThresholds();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceSettingsPage::checkerFinished()
|
void InstanceSettingsPage::checkerFinished()
|
||||||
{
|
{
|
||||||
checker.reset();
|
checker.reset();
|
||||||
@ -447,3 +452,20 @@ void InstanceSettingsPage::retranslate()
|
|||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
ui->customCommands->retranslate(); // TODO: why is this seperate from the others?
|
ui->customCommands->retranslate(); // TODO: why is this seperate from the others?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceSettingsPage::updateThresholds()
|
||||||
|
{
|
||||||
|
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
||||||
|
unsigned int maxMem = ui->maxMemSpinBox->value();
|
||||||
|
|
||||||
|
if (maxMem >= sysMiB) {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"✘");
|
||||||
|
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
|
||||||
|
} else if (maxMem > (sysMiB * 0.9)) {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"⚠");
|
||||||
|
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
|
||||||
|
} else {
|
||||||
|
ui->labelMaxMemIcon->setText(u8"✔");
|
||||||
|
ui->labelMaxMemIcon->setToolTip("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -77,10 +77,13 @@ public:
|
|||||||
virtual bool shouldDisplay() const override;
|
virtual bool shouldDisplay() const override;
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
|
void updateThresholds();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
void on_javaTestBtn_clicked();
|
void on_javaTestBtn_clicked();
|
||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
void on_maxMemSpinBox_valueChanged(int i);
|
||||||
|
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
@ -112,59 +112,29 @@
|
|||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
|
||||||
<item row="0" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelMinMem">
|
<widget class="QLabel" name="labelPermGen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Minimum memory allocation:</string>
|
<string notr="true">PermGen:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
<widget class="QLabel" name="labelMaxMem">
|
||||||
<property name="toolTip">
|
<property name="text">
|
||||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
<string>Maximum memory allocation:</string>
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> MiB</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65536</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1024</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="3" column="0" colspan="3">
|
||||||
<widget class="QSpinBox" name="minMemSpinBox">
|
<widget class="QLabel" name="labelPermgenNote">
|
||||||
<property name="toolTip">
|
<property name="text">
|
||||||
<string>The amount of memory Minecraft is started with.</string>
|
<string>Note: Permgen is set automatically by Java 8 and later</string>
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> MiB</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65536</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>256</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="2">
|
||||||
<widget class="QSpinBox" name="permGenSpinBox">
|
<widget class="QSpinBox" name="permGenSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory available to store loaded Java classes.</string>
|
<string>The amount of memory available to store loaded Java classes.</string>
|
||||||
@ -186,24 +156,67 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="labelPermGen">
|
<widget class="QSpinBox" name="maxMemSpinBox">
|
||||||
<property name="text">
|
<property name="toolTip">
|
||||||
<string notr="true">PermGen:</string>
|
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> MiB</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65536</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1024</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelMaxMem">
|
<widget class="QLabel" name="labelMinMem">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Maximum memory allocation:</string>
|
<string>Minimum memory allocation:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="labelPermgenNote">
|
<widget class="QSpinBox" name="minMemSpinBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The amount of memory Minecraft is started with.</string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> MiB</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>65536</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>256</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="labelMaxMemIcon">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Note: Permgen is set automatically by Java 8 and later</string>
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>maxMemSpinBox</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user