diff --git a/src/app/application.cpp b/src/app/application.cpp index 8300ceaa7..cde4ada94 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -216,7 +216,9 @@ void Application::setMemoryWorkingSetLimit(const int size) return; m_storeMemoryWorkingSetLimit = size; +#ifdef QBT_USES_LIBTORRENT2 applyMemoryWorkingSetLimit(); +#endif } bool Application::isFileLoggerEnabled() const @@ -595,7 +597,9 @@ void Application::processParams(const QStringList ¶ms) int Application::exec(const QStringList ¶ms) { +#ifdef QBT_USES_LIBTORRENT2 applyMemoryWorkingSetLimit(); +#endif Net::ProxyConfigurationManager::initInstance(); Net::DownloadManager::initInstance(); @@ -766,6 +770,7 @@ void Application::shutdownCleanup(QSessionManager &manager) } #endif +#ifdef QBT_USES_LIBTORRENT2 void Application::applyMemoryWorkingSetLimit() { const size_t MiB = 1024 * 1024; @@ -803,6 +808,7 @@ void Application::applyMemoryWorkingSetLimit() } #endif } +#endif void Application::cleanup() { diff --git a/src/app/application.h b/src/app/application.h index c918145f8..740445c67 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -136,7 +136,9 @@ private: void processParams(const QStringList ¶ms); void runExternalProgram(const BitTorrent::Torrent *torrent) const; void sendNotificationEmail(const BitTorrent::Torrent *torrent); +#ifdef QBT_USES_LIBTORRENT2 void applyMemoryWorkingSetLimit(); +#endif #ifndef DISABLE_GUI #ifdef Q_OS_MACOS diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 3d4b8d40d..64cfd1009 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -62,7 +62,9 @@ namespace // qBittorrent section QBITTORRENT_HEADER, RESUME_DATA_STORAGE, +#ifdef QBT_USES_LIBTORRENT2 MEMORY_WORKING_SET_LIMIT, +#endif #if defined(Q_OS_WIN) OS_MEMORY_PRIORITY, #endif @@ -178,8 +180,10 @@ void AdvancedSettings::saveAdvancedSettings() const BitTorrent::Session *const session = BitTorrent::Session::instance(); session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value()); +#ifdef QBT_USES_LIBTORRENT2 // Physical memory (RAM) usage limit app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value()); +#endif #if defined(Q_OS_WIN) session->setOSMemoryPriority(m_comboBoxOSMemoryPriority.currentData().value()); #endif @@ -407,6 +411,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 // Physical memory (RAM) usage limit m_spinBoxMemoryWorkingSetLimit.setMinimum(1); m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits::max()); @@ -415,6 +420,7 @@ void AdvancedSettings::loadAdvancedSettings() 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); +#endif #if defined(Q_OS_WIN) m_comboBoxOSMemoryPriority.addItem(tr("Normal"), QVariant::fromValue(BitTorrent::OSMemoryPriority::Normal)); m_comboBoxOSMemoryPriority.addItem(tr("Below normal"), QVariant::fromValue(BitTorrent::OSMemoryPriority::BelowNormal)); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 44c7a789d..feb0ebc92 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -61,7 +61,7 @@ private: void loadAdvancedSettings(); template void addRow(int row, const QString &text, T *widget); - QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxDiskQueueSize, + QSpinBox m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxDiskQueueSize, m_spinBoxSaveResumeDataInterval, m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS, m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark, m_spinBoxSendBufferWatermarkFactor, m_spinBoxConnectionSpeed, m_spinBoxSocketBacklogSize, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout, @@ -80,7 +80,7 @@ private: QCheckBox m_checkBoxCoalesceRW; #else QComboBox m_comboBoxDiskIOType; - QSpinBox m_spinBoxHashingThreads; + QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads; #endif // OS dependent settings diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 5ee3fca8c..9fb72df5b 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -913,7 +913,7 @@
- +   QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]