From db45c11d840acefb6dec36eeec0011cb5b5063eb Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 1 Nov 2015 02:04:58 +0800 Subject: [PATCH] Reduce max value of "Disk cache size" to 1536MB. Closes to #4028. --- src/core/preferences.cpp | 31 ++++++++++--------------------- src/gui/advancedsettings.h | 9 ++++----- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/core/preferences.cpp b/src/core/preferences.cpp index 4ede40b1c..62a2a85b5 100644 --- a/src/core/preferences.cpp +++ b/src/core/preferences.cpp @@ -1358,37 +1358,26 @@ void Preferences::setShutdownqBTWhenDownloadsComplete(bool shutdown) uint Preferences::diskCacheSize() const { uint size = value("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; +#if defined(__x86_64__) || defined(_M_X64) + size = qMin(size, (uint) 4096); // 4GiB #else - // 4GiB - if (size > 4 * 1024) - size = 4 * 1024; + // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes + // allocate 1536MiB and leave 512MiB to the rest of program data in RAM + size = qMin(size, (uint) 1536); #endif - return size; } void Preferences::setDiskCacheSize(uint 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; +#if defined(__x86_64__) || defined(_M_X64) + size = qMin(size, (uint) 4096); // 4GiB #else - // 4GiB - if (size0 > 4 * 1024) - size0 = 4 * 1024; + // allocate 1536MiB and leave 512MiB to the rest of program data in RAM + size = qMin(size, (uint) 1536); #endif - - setValue("Preferences/Downloads/DiskWriteCacheSize", size0); + setValue("Preferences/Downloads/DiskWriteCacheSize", size); } uint Preferences::diskCacheTTL() const diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index e2259932d..ae659945d 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -208,12 +208,11 @@ private slots: spin_cache.setMinimum(0); // 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); +#if defined(__x86_64__) || defined(_M_X64) + spin_cache.setMaximum(4096); #else - // 4GiB - spin_cache.setMaximum(4*1024); + // allocate 1536MiB and leave 512MiB to the rest of program data in RAM + spin_cache.setMaximum(1536); #endif spin_cache.setValue(pref->diskCacheSize()); updateCacheSpinSuffix(spin_cache.value());