From b79ac0d71695cd5d149dcb2124c848a21be0510c Mon Sep 17 00:00:00 2001 From: Hanabishi <13597663+HanabishiRecca@users.noreply.github.com> Date: Mon, 12 May 2025 21:49:18 +0500 Subject: [PATCH] Remove "Physical memory (RAM) usage limit" option on Linux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Memory working set limit is not effective on Linux at all. See [`getrlimit(2)`](https://man7.org/linux/man-pages/man2/getrlimit.2.html) → `RLIMIT_RSS`. Introduced in #16874, disabled for macOS in #19805. This PR hides the option for Linux too. Worth to mention that #19805 did not deliver the change for WebUI. So there is also a small fixup, I covered both cases. Also removed pointless "This option is less effective on Linux" remark. PR #22680. --- src/app/application.cpp | 6 +++--- src/gui/advancedsettings.cpp | 7 +++---- src/gui/advancedsettings.h | 2 +- src/webui/www/private/views/preferences.html | 5 ++++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index a6666c57e..8fe47033e 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -410,7 +410,7 @@ void Application::setMemoryWorkingSetLimit(const int size) return; m_storeMemoryWorkingSetLimit = size; -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) applyMemoryWorkingSetLimit(); #endif } @@ -844,7 +844,7 @@ int Application::exec() printf("%s\n", qUtf8Printable(loadingStr)); #endif -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) applyMemoryWorkingSetLimit(); #endif @@ -1202,7 +1202,7 @@ void Application::shutdownCleanup([[maybe_unused]] QSessionManager &manager) } #endif -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) void Application::applyMemoryWorkingSetLimit() const { const size_t MiB = 1024 * 1024; diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index b5a56f936..ba620e027 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -64,7 +64,7 @@ namespace QBITTORRENT_HEADER, RESUME_DATA_STORAGE, TORRENT_CONTENT_REMOVE_OPTION, -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) MEMORY_WORKING_SET_LIMIT, #endif #if defined(Q_OS_WIN) @@ -209,7 +209,7 @@ void AdvancedSettings::saveAdvancedSettings() const BitTorrent::Session *const session = BitTorrent::Session::instance(); session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value()); -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) // Physical memory (RAM) usage limit app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value()); #endif @@ -494,12 +494,11 @@ void AdvancedSettings::loadAdvancedSettings() m_comboBoxTorrentContentRemoveOption.setCurrentIndex(m_comboBoxTorrentContentRemoveOption.findData(QVariant::fromValue(session->torrentContentRemoveOption()))); addRow(TORRENT_CONTENT_REMOVE_OPTION, tr("Torrent content removing mode"), &m_comboBoxTorrentContentRemoveOption); -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) // Physical memory (RAM) usage limit m_spinBoxMemoryWorkingSetLimit.setMinimum(1); m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits::max()); m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB")); - m_spinBoxMemoryWorkingSetLimit.setToolTip(tr("This option is less effective on Linux")); m_spinBoxMemoryWorkingSetLimit.setValue(app()->memoryWorkingSetLimit()); addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit") + u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set", u"(?)")) , &m_spinBoxMemoryWorkingSetLimit); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 2305e830a..7ffca4f33 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -93,7 +93,7 @@ private: QSpinBox m_spinBoxHashingThreads; #endif -#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_LINUX) && !defined(Q_OS_MACOS) QSpinBox m_spinBoxMemoryWorkingSetLimit; #endif diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 1ea44c725..15770a5e5 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -1159,7 +1159,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD -   QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog] +   QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog] @@ -3164,6 +3164,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD document.getElementById("diskIOWriteModeWriteThrough").style.display = "none"; } + if ((buildInfo.platform === "linux") || (buildInfo.platform === "macos")) + document.getElementById("rowMemoryWorkingSetLimit").style.display = "none"; + if ((buildInfo.platform !== "macos") && (buildInfo.platform !== "windows")) document.getElementById("rowMarkOfTheWeb").style.display = "none";