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

Unified Diff: webkit/glue/webkit_glue.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 Created 8 years, 8 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
Index: webkit/glue/webkit_glue.cc
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 496b837469889c2ff833e5b450572870bcf85a00..03286f2dbf7a238aa2ab32425ce43f931ff5a01d 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -46,6 +46,9 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/win/WebInputEventFactory.h"
#endif
#include "v8/include/v8.h"
+#if defined(OS_ANDROID)
+#include "webkit/glue/dalvik_heap_size_android.h"
+#endif
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/user_agent.h"
@@ -81,6 +84,16 @@ bool g_forcefully_terminate_plugin_process = false;
void SetJavaScriptFlags(const std::string& str) {
#if WEBKIT_USING_V8
+#if defined(OS_ANDROID)
+ DalvikHeapSize* heap_size_singleton = DalvikHeapSize::GetInstance();
+ // Set V8 heap size to 3/4 of the device heap size.
+ int heap_size = std::max(32, heap_size_singleton->HeapSizeMB() / 4 * 3);
jamesr 2012/04/20 00:44:26 you're clamping the heap size in dalvik_heap_size_
ulan 2012/04/20 08:55:43 This heap size is for setting V8 heap limit, which
+ int code_size = heap_size / 4;
+ std::string heap_flags = base::StringPrintf(
+ "--max_old_gen_size=%d --max_executable_size=%d", heap_size, code_size);
jamesr 2012/04/20 00:44:26 formatting a string flag is really hacky and very
ulan 2012/04/20 08:55:43 Okay, removing this part from CL, will set this vi
+ v8::V8::SetFlagsFromString(heap_flags.data(),
+ static_cast<int>(heap_flags.size()));
+#endif
v8::V8::SetFlagsFromString(str.data(), static_cast<int>(str.size()));
#endif
}

Powered by Google App Engine
This is Rietveld 408576698