mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06: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.
This commit is contained in:
@@ -220,7 +220,9 @@ void Application::setMemoryWorkingSetLimit(const int size)
|
||||
return;
|
||||
|
||||
m_storeMemoryWorkingSetLimit = size;
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
applyMemoryWorkingSetLimit();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -621,7 +623,7 @@ void Application::processParams(const QStringList ¶ms)
|
||||
|
||||
int Application::exec(const QStringList ¶ms)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2))
|
||||
applyMemoryWorkingSetLimit();
|
||||
#endif
|
||||
|
||||
@@ -794,7 +796,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2))
|
||||
void Application::applyMemoryWorkingSetLimit()
|
||||
{
|
||||
const SIZE_T UNIT_SIZE = 1024 * 1024; // MiB
|
||||
|
||||
@@ -126,7 +126,7 @@ private slots:
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef Q_OS_WIN
|
||||
#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2))
|
||||
void applyMemoryWorkingSetLimit();
|
||||
#endif
|
||||
void initializeTranslation();
|
||||
|
||||
@@ -62,9 +62,11 @@ namespace
|
||||
// qBittorrent section
|
||||
QBITTORRENT_HEADER,
|
||||
RESUME_DATA_STORAGE,
|
||||
#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2))
|
||||
MEMORY_WORKING_SET_LIMIT,
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
OS_MEMORY_PRIORITY,
|
||||
MEMORY_WORKING_SET_LIMIT,
|
||||
#endif
|
||||
// network interface
|
||||
NETWORK_IFACE,
|
||||
@@ -198,7 +200,9 @@ void AdvancedSettings::saveAdvancedSettings()
|
||||
}
|
||||
session->setOSMemoryPriority(prio);
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
static_cast<Application *>(QCoreApplication::instance())->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
|
||||
#endif
|
||||
#endif
|
||||
// Async IO threads
|
||||
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
|
||||
@@ -443,6 +447,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
+ ' ' + makeLink("https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", "(?)"))
|
||||
, &m_comboBoxOSMemoryPriority);
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
m_spinBoxMemoryWorkingSetLimit.setMinimum(1);
|
||||
m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits<int>::max());
|
||||
m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB"));
|
||||
@@ -451,6 +456,7 @@ void AdvancedSettings::loadAdvancedSettings()
|
||||
addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit")
|
||||
+ ' ' + makeLink("https://wikipedia.org/wiki/Working_set", "(?)"))
|
||||
, &m_spinBoxMemoryWorkingSetLimit);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Async IO threads
|
||||
|
||||
@@ -82,8 +82,10 @@ private:
|
||||
// OS dependent settings
|
||||
#if defined(Q_OS_WIN)
|
||||
QComboBox m_comboBoxOSMemoryPriority;
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
QSpinBox m_spinBoxMemoryWorkingSetLimit;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
QCheckBox m_checkBoxIconsInMenusEnabled;
|
||||
|
||||
Reference in New Issue
Block a user