Index: third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp |
index 35d5d5ee5cd59a950e9271c596e920f3a4513bbb..dce13caa9a574275ca3df2f613e59d51c2db80ce 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp |
@@ -96,6 +96,13 @@ static void reportFatalErrorInMainThread(const char* location, const char* messa |
CRASH(); |
} |
+static void reportOOMErrorInMainThread(const char* location, bool isJsHeap) |
+{ |
+ int memoryUsageMB = Platform::current()->actualMemoryUsageMB(); |
+ printf("V8 %s OOM: (%s). Current memory usage: %d MB\n", isJsHeap ? "javascript" : "process", location, memoryUsageMB); |
haraken
2016/07/15 16:01:23
We should avoid using printf. Use WTF_LOG instead.
Will Harris
2016/07/15 16:11:41
Done. WTF_LOG is deprecated so I used VLOG.
|
+ OOM_CRASH(); |
+} |
+ |
static String extractMessageForConsole(v8::Isolate* isolate, v8::Local<v8::Value> data) |
{ |
if (V8DOMWrapper::isWrapper(isolate, data)) { |
@@ -356,6 +363,7 @@ void V8Initializer::initializeMainThread() |
initializeV8Common(isolate); |
+ isolate->SetOOMErrorHandler(reportOOMErrorInMainThread); |
isolate->SetFatalErrorHandler(reportFatalErrorInMainThread); |
isolate->AddMessageListener(messageHandlerInMainThread); |
isolate->SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMainThread); |