bug 454587 Make sure that don't disable memory cache when
authorChristian Biesinger <cbiesinger@gmail.com>
Sun, 14 Sep 2008 15:45:52 -0700
changeset 19243 f50f7928622d8b1ae530d97d0c3714e4f64a612a
parent 19242 19030b97ca13c342e5116c128cbe604d2905c0ab
child 19244 72ebd32e60335d4dcef434c5b9997c1788ffad9b
push idunknown
push userunknown
push dateunknown
bugs454587
milestone1.9.1b1pre
bug 454587 Make sure that don't disable memory cache when PR_GetPhysicalMemory() fails. Instead, default to 32 MB of memory (2 MB cache size) r+sr=bz
netwerk/cache/src/nsCacheService.cpp
--- a/netwerk/cache/src/nsCacheService.cpp
+++ b/netwerk/cache/src/nsCacheService.cpp
@@ -521,18 +521,21 @@ nsCacheProfilePrefObserver::MemoryCacheC
     if (capacity >= 0) {
         CACHE_LOG_DEBUG(("Memory cache capacity forced to %d\n", capacity));
         return capacity;
     }
 
     PRUint64 bytes = PR_GetPhysicalMemorySize();
     CACHE_LOG_DEBUG(("Physical Memory size is %llu\n", bytes));
 
-    if (LL_CMP(bytes, ==, LL_ZERO))
-        return 0;
+    // If getting the physical memory failed, arbitrarily assume
+    // 32 MB of RAM. We use a low default to have a reasonable
+    // size on all the devices we support.
+    if (bytes == 0)
+        bytes = 32 * 1024 * 1024;
 
     // Conversion from unsigned int64 to double doesn't work on all platforms.
     // We need to truncate the value at LL_MAXINT to make sure we don't
     // overflow.
     if (LL_CMP(bytes, >, LL_MAXINT))
         bytes = LL_MAXINT;
 
     PRUint64 kbytes;