mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Limit max cache to 1800MiB for 32bits compiled binaries and to 4GiB for other. Closes #1698.
Conflicts: src/preferences/advancedsettings.h src/preferences/preferences.cpp
This commit is contained in:
parent
d845b57ad1
commit
dac8e20aad
2 changed files with 37 additions and 3 deletions
|
@ -178,7 +178,15 @@ private slots:
|
||||||
const Preferences pref;
|
const Preferences pref;
|
||||||
// Disk write cache
|
// Disk write cache
|
||||||
spin_cache.setMinimum(0);
|
spin_cache.setMinimum(0);
|
||||||
spin_cache.setMaximum(2048);
|
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
|
||||||
|
// These macros may not be available on compilers other than MSVC and GCC
|
||||||
|
#if !defined(_M_X64) || !defined(__amd64__)
|
||||||
|
//1800MiB to leave 248MiB room to the rest of program data in RAM
|
||||||
|
spin_cache.setMaximum(1800);
|
||||||
|
#else
|
||||||
|
// 4GiB
|
||||||
|
spin_cache.setMaximum(4*1024);
|
||||||
|
#endif
|
||||||
spin_cache.setValue(pref.diskCacheSize());
|
spin_cache.setValue(pref.diskCacheSize());
|
||||||
updateCacheSpinSuffix(spin_cache.value());
|
updateCacheSpinSuffix(spin_cache.value());
|
||||||
setRow(DISK_CACHE, tr("Disk write cache size"), &spin_cache);
|
setRow(DISK_CACHE, tr("Disk write cache size"), &spin_cache);
|
||||||
|
|
|
@ -985,14 +985,40 @@ public:
|
||||||
|
|
||||||
uint diskCacheSize() const {
|
uint diskCacheSize() const {
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1610
|
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 0).toUInt();
|
uint size = value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 0).toUInt();
|
||||||
|
|
||||||
|
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
|
||||||
|
// These macros may not be available on compilers other than MSVC and GCC
|
||||||
|
#if !defined(_M_X64) || !defined(__amd64__)
|
||||||
|
//1800MiB to leave 248MiB room to the rest of program data in RAM
|
||||||
|
if (size > 1800)
|
||||||
|
size = 1800;
|
||||||
|
#else
|
||||||
|
// 4GiB
|
||||||
|
if (size > 4*1024)
|
||||||
|
size = 4*1024;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return size;
|
||||||
#else
|
#else
|
||||||
return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 128).toUInt();
|
return value(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), 128).toUInt();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDiskCacheSize(uint size) {
|
void setDiskCacheSize(uint size) {
|
||||||
setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), size);
|
uint size0 = size;
|
||||||
|
|
||||||
|
#if !defined(_M_X64) || !defined(__amd64__)
|
||||||
|
//1800MiB to leave 248MiB room to the rest of program data in RAM
|
||||||
|
if (size0 > 1800)
|
||||||
|
size0 = 1800;
|
||||||
|
#else
|
||||||
|
// 4GiB
|
||||||
|
if (size0 > 4*1024)
|
||||||
|
size0 = 4*1024;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setValue(QString::fromUtf8("Preferences/Downloads/DiskWriteCacheSize"), size0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBTORRENT_VERSION_NUM >= 1610
|
#if LIBTORRENT_VERSION_NUM >= 1610
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue