Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: webkit/glue/webkitplatformsupport_impl.cc

Issue 10113009: Set Android/V8 memory limits from dalvik.vm.heapsize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, rebase Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webkitplatformsupport_impl.cc
diff --git a/webkit/glue/webkitplatformsupport_impl.cc b/webkit/glue/webkitplatformsupport_impl.cc
index 73e2e0859c6299d66ca599dab2ec26c34de4a907..6003cce1c4ffea8838b2c85130904d4213f15281 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"
@@ -668,8 +669,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)
@@ -683,10 +684,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
@@ -696,10 +695,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());
@@ -715,14 +712,7 @@ static size_t getMemoryUsageMB(bool bypass_cache) {
mem_usage_cache_singleton->IsCachedValueValid(&current_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;
}
@@ -735,6 +725,29 @@ 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() {
+ // If memory usage is above highMemoryUsageMB() and memory usage increased by
+ // more than highUsageDeltaMB() since the last GC, then force GC.
+ // Note that this limit should be greater than the amount of memory for V8
+ // internal data structures that are released on GC and reallocated during JS
+ // execution (about 8MB). Otherwise, it will cause too aggressive GCs.
+ return base::SysInfo::DalvikHeapSizeMB() / 8;
+}
+#endif
+
void WebKitPlatformSupportImpl::SuspendSharedTimer() {
++shared_timer_suspended_;
}
« no previous file with comments | « webkit/glue/webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698