mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
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.
This commit is contained in:
parent
0e989185ce
commit
cc0a0b56ed
5 changed files with 17 additions and 3 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<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()
|
|||
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()
|
|||
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));
|
||||
|
|
|
@ -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:
|
|||
QCheckBox m_checkBoxCoalesceRW;
|
||||
#else
|
||||
QComboBox m_comboBoxDiskIOType;
|
||||
QSpinBox m_spinBoxHashingThreads;
|
||||
QSpinBox m_spinBoxMemoryWorkingSetLimit, m_spinBoxHashingThreads;
|
||||
#endif
|
||||
|
||||
// OS dependent settings
|
||||
|
|
|
@ -913,7 +913,7 @@
|
|||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="memoryWorkingSetLimit">QBT_TR(Physical memory (RAM) usage limit:)QBT_TR[CONTEXT=OptionsDialog] <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] <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]"> QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
|
||||
|
|
Loading…
Reference in a new issue