From bb6d69f8b7f2786f14c29418b279b2bd5b78b545 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 29 Oct 2023 17:41:38 +0800 Subject: [PATCH] =?UTF-8?q?Remove=20"Physical=20memory=20(RAM)=20usage=20l?= =?UTF-8?q?imit"=20option=20on=20macOS=C2=A0#19805?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This has no effect on macOS. https://stackoverflow.com/questions/3274385/how-to-limit-memory-of-a-os-x-program-ulimit-v-neither-m-are-working Closes #18656. PR #19805. --- src/app/application.cpp | 6 +++--- src/app/application.h | 2 +- src/gui/advancedsettings.cpp | 6 +++--- src/gui/advancedsettings.h | 7 ++++++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 0fb60f83f..f70293031 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -375,7 +375,7 @@ void Application::setMemoryWorkingSetLimit(const int size) return; m_storeMemoryWorkingSetLimit = size; -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) applyMemoryWorkingSetLimit(); #endif } @@ -773,7 +773,7 @@ int Application::exec() printf("%s\n", qUtf8Printable(loadingStr)); #endif -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) applyMemoryWorkingSetLimit(); #endif @@ -1080,7 +1080,7 @@ void Application::shutdownCleanup(QSessionManager &manager) } #endif -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) void Application::applyMemoryWorkingSetLimit() const { const size_t MiB = 1024 * 1024; diff --git a/src/app/application.h b/src/app/application.h index ee69f5afc..76a12ffb3 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -154,7 +154,7 @@ private: void runExternalProgram(const QString &programTemplate, const BitTorrent::Torrent *torrent) const; void sendNotificationEmail(const BitTorrent::Torrent *torrent); -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) void applyMemoryWorkingSetLimit() const; #endif diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index af665fdae..b116f2d4d 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -63,7 +63,7 @@ namespace // qBittorrent section QBITTORRENT_HEADER, RESUME_DATA_STORAGE, -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) MEMORY_WORKING_SET_LIMIT, #endif #if defined(Q_OS_WIN) @@ -195,7 +195,7 @@ void AdvancedSettings::saveAdvancedSettings() const BitTorrent::Session *const session = BitTorrent::Session::instance(); session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value()); -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) // Physical memory (RAM) usage limit app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value()); #endif @@ -451,7 +451,7 @@ void AdvancedSettings::loadAdvancedSettings() m_comboBoxResumeDataStorage.setCurrentIndex(m_comboBoxResumeDataStorage.findData(QVariant::fromValue(session->resumeDataStorageType()))); addRow(RESUME_DATA_STORAGE, tr("Resume data storage type (requires restart)"), &m_comboBoxResumeDataStorage); -#ifdef QBT_USES_LIBTORRENT2 +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) // Physical memory (RAM) usage limit m_spinBoxMemoryWorkingSetLimit.setMinimum(1); m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits::max()); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 652cd88ac..3622fa787 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -88,7 +89,11 @@ private: QCheckBox m_checkBoxCoalesceRW; #else QComboBox m_comboBoxDiskIOType; - QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads; + QSpinBox m_spinBoxHashingThreads; +#endif + +#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS) + QSpinBox m_spinBoxMemoryWorkingSetLimit; #endif #if defined(QBT_USES_LIBTORRENT2) && TORRENT_USE_I2P