Browse Source

Make working set limit available only on libtorrent 2.0.x builds

You can already control the cache size in libtorrent 1.2.x so it doesn't make sense to implement this limit for all use cases. Also there are some downsides to using working set size to limit memory usage such as unresponsive GUI when limit gets hit.

PR #17275.
adaptive-webui-19844
summer 3 years ago committed by GitHub
parent
commit
cc0a0b56ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/app/application.cpp
  2. 2
      src/app/application.h
  3. 6
      src/gui/advancedsettings.cpp
  4. 4
      src/gui/advancedsettings.h
  5. 2
      src/webui/www/private/views/preferences.html

6
src/app/application.cpp

@ -216,7 +216,9 @@ void Application::setMemoryWorkingSetLimit(const int size) @@ -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 &params) @@ -595,7 +597,9 @@ void Application::processParams(const QStringList &params)
int Application::exec(const QStringList &params)
{
#ifdef QBT_USES_LIBTORRENT2
applyMemoryWorkingSetLimit();
#endif
Net::ProxyConfigurationManager::initInstance();
Net::DownloadManager::initInstance();
@ -766,6 +770,7 @@ void Application::shutdownCleanup(QSessionManager &manager) @@ -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() @@ -803,6 +808,7 @@ void Application::applyMemoryWorkingSetLimit()
}
#endif
}
#endif
void Application::cleanup()
{

2
src/app/application.h

@ -136,7 +136,9 @@ private: @@ -136,7 +136,9 @@ private:
void processParams(const QStringList &params);
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

6
src/gui/advancedsettings.cpp

@ -62,7 +62,9 @@ namespace @@ -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 @@ -178,8 +180,10 @@ void AdvancedSettings::saveAdvancedSettings() const
BitTorrent::Session *const session = BitTorrent::Session::instance();
session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value<BitTorrent::ResumeDataStorageType>());
#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<BitTorrent::OSMemoryPriority>());
#endif
@ -407,6 +411,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -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<int>::max());
@ -415,6 +420,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -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));

4
src/gui/advancedsettings.h

@ -61,7 +61,7 @@ private: @@ -61,7 +61,7 @@ private:
void loadAdvancedSettings();
template <typename T> 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: @@ -80,7 +80,7 @@ private:
QCheckBox m_checkBoxCoalesceRW;
#else
QComboBox m_comboBoxDiskIOType;
QSpinBox m_spinBoxHashingThreads;
QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads;
#endif
// OS dependent settings

2
src/webui/www/private/views/preferences.html

@ -913,7 +913,7 @@ @@ -913,7 +913,7 @@
<table>
<tr>
<td>
<label for="memoryWorkingSetLimit">QBT_TR(Physical memory (RAM) usage limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://wikipedia.org/wiki/Working_set" target="_blank">(?)</a></label>
<label for="memoryWorkingSetLimit">QBT_TR(Physical memory (RAM) usage limit (applied if libtorrent >= 2.0):)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://wikipedia.org/wiki/Working_set" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="memoryWorkingSetLimit" style="width: 15em;" title="QBT_TR(This option is less effective on Linux)QBT_TR[CONTEXT=OptionsDialog]">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]

Loading…
Cancel
Save