From c00b6f2a0a92765f92a32591df7b55c1416adafb Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 3 Jun 2011 07:00:08 -0700 Subject: [PATCH] Bug 661351 - Clean up code that worked around bad values from PR_GetPhysicalMemorySize [r=mak] --- toolkit/components/places/nsNavHistory.cpp | 15 ++++++--------- toolkit/components/places/nsPlacesExpiration.js | 9 +++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 7177ae4f484..de24f17d9dd 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -135,11 +135,8 @@ using namespace mozilla::places; // Out of this cache, SQLite will use at most the size of the database file. #define DATABASE_DEFAULT_CACHE_TO_MEMORY_PERCENTAGE 6 -// PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036). If the -// return value is greater than MEMSIZE_MAX_BYTES, assume it is garbage and -// use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync with the code in -// nsPlacesExpiration.js. -#define MEMSIZE_MAX_BYTES 137438953472LL // 128 G +// If the physical memory size is not available, use MEMSIZE_FALLBACK_BYTES +// instead. Must stay in sync with the code in nsPlacesExpiration.js. #define MEMSIZE_FALLBACK_BYTES 268435456 // 256 M // Maximum size for the WAL file. It should be small enough since in case of @@ -733,14 +730,14 @@ nsNavHistory::InitDB() if (cachePercentage < 0) cachePercentage = 0; - static PRInt64 physMem = PR_GetPhysicalMemorySize(); - if (physMem <= 0 || physMem > MEMSIZE_MAX_BYTES) + static PRUint64 physMem = PR_GetPhysicalMemorySize(); + if (physMem == 0) physMem = MEMSIZE_FALLBACK_BYTES; - PRInt64 cacheSize = physMem * cachePercentage / 100; + PRUint64 cacheSize = physMem * cachePercentage / 100; // Compute number of cached pages, this will be our cache size. - PRInt64 cachePages = cacheSize / mDBPageSize; + PRUint64 cachePages = cacheSize / mDBPageSize; nsCAutoString cacheSizePragma("PRAGMA cache_size = "); cacheSizePragma.AppendInt(cachePages); rv = mDBConn->ExecuteSimpleSQL(cacheSizePragma); diff --git a/toolkit/components/places/nsPlacesExpiration.js b/toolkit/components/places/nsPlacesExpiration.js index cedd5c8745e..56d6f8d0368 100644 --- a/toolkit/components/places/nsPlacesExpiration.js +++ b/toolkit/components/places/nsPlacesExpiration.js @@ -717,17 +717,14 @@ nsPlacesExpiration.prototype = { catch(e) {} if (this._urisLimit < 0) { - // PR_GetPhysicalMemorySize sometimes returns garbage (bug 660036). - // If the return value is greater than MEMSIZE_MAX_BYTES, assume it is - // garbage and use MEMSIZE_FALLBACK_BYTES instead. Must stay in sync - // with the code in nsNavHistory.cpp. - const MEMSIZE_MAX_BYTES = 137438953472; // 128 G + // If physical memory size is not available, use MEMSIZE_FALLBACK_BYTES + // instead. Must stay in sync with the code in nsNavHistory.cpp. const MEMSIZE_FALLBACK_BYTES = 268435456; // 256 M // The preference did not exist or has a negative value, so we calculate a // limit based on hardware. let memsize = this._sys.getProperty("memsize"); // Memory size in bytes. - if (memsize <= 0 || memsize > MEMSIZE_MAX_BYTES) + if (memsize <= 0) memsize = MEMSIZE_FALLBACK_BYTES; let cpucount = this._sys.getProperty("cpucount"); // CPU count.