1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-03-09 11:51:03 +00:00

Allow disabling of OS cache. This will prevent RAM increases on Windows when seeding many files. Closes #1699.

This commit is contained in:
sledgehammer999 2014-08-07 22:30:54 +03:00
parent 7763a6d2d5
commit 80d6a5a73e
4 changed files with 20 additions and 2 deletions

View File

@ -13,7 +13,7 @@
#include "preferences.h"
enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OS_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
UPDATE_CHECK,
#endif
@ -29,7 +29,7 @@ class AdvancedSettings: public QTableWidget {
private:
QSpinBox spin_cache, outgoing_ports_min, outgoing_ports_max, spin_list_refresh, spin_maxhalfopen, spin_tracker_port;
QCheckBox cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
QCheckBox cb_os_cache, cb_ignore_limits_lan, cb_recheck_completed, cb_resolve_countries, cb_resolve_hosts,
cb_super_seeding, cb_program_notifications, cb_tracker_status, cb_confirm_torrent_deletion,
cb_enable_tracker_ext;
QComboBox combo_iface;
@ -71,6 +71,8 @@ public slots:
// Disk write cache
pref->setDiskCacheSize(spin_cache.value());
pref->setDiskCacheTTL(spin_cache_ttl.value());
// Enable OS cache
pref->setOsCache(cb_os_cache.isChecked());
// Outgoing ports
pref->setOutgoingPortsMin(outgoing_ports_min.value());
pref->setOutgoingPortsMax(outgoing_ports_max.value());
@ -188,6 +190,9 @@ private slots:
spin_cache_ttl.setValue(pref->diskCacheTTL());
spin_cache_ttl.setSuffix(tr(" s", " seconds"));
setRow(DISK_CACHE_TTL, tr("Disk cache expiry interval"), &spin_cache_ttl);
// Enable OS cache
cb_os_cache.setChecked(pref->osCache());
setRow(OS_CACHE, tr("Enable OS cache"), &cb_os_cache);
// Outgoing port Min
outgoing_ports_min.setMinimum(0);
outgoing_ports_min.setMaximum(65535);

View File

@ -1139,6 +1139,14 @@ void Preferences::setDiskCacheTTL(uint ttl) {
setValue("Preferences/Downloads/DiskWriteCacheTTL", ttl);
}
bool Preferences::osCache() const {
return value("Preferences/Advanced/osCache", true).toBool();
}
void Preferences::setOsCache(bool enable) {
setValue("Preferences/Advanced/osCache", enable);
}
uint Preferences::outgoingPortsMin() const {
return value("Preferences/Advanced/OutgoingPortsMin", 0).toUInt();
}

View File

@ -308,6 +308,8 @@ public:
void setDiskCacheSize(uint size);
uint diskCacheTTL() const;
void setDiskCacheTTL(uint ttl);
bool osCache() const;
void setOsCache(bool enable);
uint outgoingPortsMin() const;
void setOutgoingPortsMin(uint val);
uint outgoingPortsMax() const;

View File

@ -411,6 +411,9 @@ void QBtSession::configureSession() {
sessionSettings.cache_size = cache_size ? cache_size * 64 : -1;
sessionSettings.cache_expiry = pref->diskCacheTTL();
qDebug() << "Using a disk cache size of" << cache_size << "MiB";
session_settings::io_buffer_mode_t mode = pref->osCache() ? session_settings::enable_os_cache : session_settings::disable_os_cache;
sessionSettings.disk_io_read_mode = mode;
sessionSettings.disk_io_write_mode = mode;
sessionSettings.anonymous_mode = pref->isAnonymousModeEnabled();
if (sessionSettings.anonymous_mode) {
addConsoleMessage(tr("Anonymous mode [ON]"), "blue");