Index: webkit/glue/webkitplatformsupport_impl.cc |
diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc |
index 7b7ab157875b2f29e8c8bed55605ed95fdf579c7..0ff7d8006c9888c43154d25bd06ff55f0070ecc8 100644 |
--- a/webkit/glue/webkitplatformsupport_impl.cc |
+++ b/webkit/glue/webkitplatformsupport_impl.cc |
@@ -24,6 +24,7 @@ |
#include "base/string_number_conversions.h" |
#include "base/string_util.h" |
#include "base/synchronization/lock.h" |
+#include "base/sys_info.h" |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
#include "grit/webkit_chromium_resources.h" |
@@ -620,8 +621,8 @@ WebKit::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( |
return WebKit::WebString(""); |
} |
-#if defined(OS_LINUX) |
-static size_t memoryUsageMBLinux() { |
+#if defined(OS_LINUX) || defined(OS_ANDROID) |
+static size_t memoryUsageMB() { |
struct mallinfo minfo = mallinfo(); |
uint64_t mem_usage = |
#if defined(USE_TCMALLOC) |
@@ -635,10 +636,8 @@ static size_t memoryUsageMBLinux() { |
v8::V8::GetHeapStatistics(&stat); |
return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 20); |
} |
-#endif |
- |
-#if defined(OS_MACOSX) |
-static size_t memoryUsageMBMac() { |
+#elif defined(OS_MACOSX) |
+static size_t memoryUsageMB() { |
using base::ProcessMetrics; |
static ProcessMetrics* process_metrics = |
// The default port provider is sufficient to get data for the current |
@@ -648,10 +647,8 @@ static size_t memoryUsageMBMac() { |
DCHECK(process_metrics); |
return process_metrics->GetWorkingSetSize() >> 20; |
} |
-#endif |
- |
-#if !defined(OS_LINUX) && !defined(OS_MACOSX) |
-static size_t memoryUsageMBGeneric() { |
+#else |
+static size_t memoryUsageMB() { |
using base::ProcessMetrics; |
static ProcessMetrics* process_metrics = |
ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle()); |
@@ -667,14 +664,7 @@ static size_t getMemoryUsageMB(bool bypass_cache) { |
mem_usage_cache_singleton->IsCachedValueValid(¤t_mem_usage)) |
return current_mem_usage; |
- current_mem_usage = |
-#if defined(OS_LINUX) |
- memoryUsageMBLinux(); |
-#elif defined(OS_MACOSX) |
- memoryUsageMBMac(); |
-#else |
- memoryUsageMBGeneric(); |
-#endif |
+ current_mem_usage = memoryUsageMB(); |
mem_usage_cache_singleton->SetMemoryValue(current_mem_usage); |
return current_mem_usage; |
} |
@@ -687,6 +677,27 @@ size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() { |
return getMemoryUsageMB(true); |
} |
+#if defined(OS_ANDROID) |
+size_t WebKitPlatformSupportImpl::lowMemoryUsageMB() { |
+ // If memory usage is below this threshold, do not bother forcing GC. |
+ // Allow us to use up to our memory class value before V8's GC kicks in. |
+ // These values have been determined by experimentation. |
+ return base::SysInfo::DalvikHeapSizeMB() / 2; |
+} |
+ |
+size_t WebKitPlatformSupportImpl::highMemoryUsageMB() { |
+ // If memory usage is above this threshold, force GC more aggressively. |
+ return base::SysInfo::DalvikHeapSizeMB() * 3 / 4; |
+} |
+ |
+size_t WebKitPlatformSupportImpl::highUsageDeltaMB() { |
+ // Threshold of delta of memory usage growth (vs. last working set estimate) |
+ // to force GC when memory usage is high. |
+ // Avoid constant V8 GC when memory usage equals to working set estimate. |
Satish
2012/05/16 11:23:51
Can you mention here that this should be sufficien
ulan
2012/05/16 11:46:40
Done.
|
+ return base::SysInfo::DalvikHeapSizeMB() / 8; |
+} |
+#endif |
+ |
void WebKitPlatformSupportImpl::SuspendSharedTimer() { |
++shared_timer_suspended_; |
} |