Browse Source

Disable "limit virtual memory" routine on macOS

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.
adaptive-webui-19844
Chocobo1 1 year ago committed by GitHub
parent
commit
7bd8f262db
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. 7
      src/gui/advancedsettings.h

6
src/app/application.cpp

@ -373,7 +373,7 @@ void Application::setMemoryWorkingSetLimit(const int size) @@ -373,7 +373,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
}
@ -782,7 +782,7 @@ int Application::exec() @@ -782,7 +782,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
@ -1134,7 +1134,7 @@ void Application::shutdownCleanup([[maybe_unused]] QSessionManager &manager) @@ -1134,7 +1134,7 @@ void Application::shutdownCleanup([[maybe_unused]] 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;

2
src/app/application.h

@ -159,7 +159,7 @@ private: @@ -159,7 +159,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

6
src/gui/advancedsettings.cpp

@ -63,7 +63,7 @@ namespace @@ -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)
@ -197,7 +197,7 @@ void AdvancedSettings::saveAdvancedSettings() const @@ -197,7 +197,7 @@ void AdvancedSettings::saveAdvancedSettings() const
BitTorrent::Session *const session = BitTorrent::Session::instance();
session->setResumeDataStorageType(m_comboBoxResumeDataStorage.currentData().value<BitTorrent::ResumeDataStorageType>());
#ifdef QBT_USES_LIBTORRENT2
#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
// Physical memory (RAM) usage limit
app()->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value());
#endif
@ -456,7 +456,7 @@ void AdvancedSettings::loadAdvancedSettings() @@ -456,7 +456,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<int>::max());

7
src/gui/advancedsettings.h

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#include <libtorrent/config.hpp>
#include <QtSystemDetection>
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
@ -88,7 +89,11 @@ private: @@ -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

Loading…
Cancel
Save