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

Unified Diff: third_party/WebKit/Source/platform/heap/ThreadState.cpp

Issue 1358813002: Oilpan: We shouldn't trigger too many conservative GCs when detaching iframes Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/ThreadState.cpp
diff --git a/third_party/WebKit/Source/platform/heap/ThreadState.cpp b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
index 9222e8bb75494167a15e14433158469e96e62842..d0303fafe1e8c8e7694a70d13570fd365f143267 100644
--- a/third_party/WebKit/Source/platform/heap/ThreadState.cpp
+++ b/third_party/WebKit/Source/platform/heap/ThreadState.cpp
@@ -99,6 +99,7 @@ ThreadState::ThreadState()
, m_gcForbiddenCount(0)
, m_persistentAllocated(0)
, m_persistentFreed(0)
+ , m_disposedV8ContextCount(0)
, m_vectorBackingHeapIndex(Vector1HeapIndex)
, m_currentHeapAges(0)
, m_isTerminating(false)
@@ -731,6 +732,27 @@ void ThreadState::schedulePageNavigationGC()
setGCState(PageNavigationGCScheduled);
}
+void ThreadState::v8ContextCreated()
+{
+ if (m_disposedV8ContextCount >= 5) {
+ // A frame retains a lot of memory in the V8 side. V8's GC cannot
+ // collect the memory until Oilpan's GC collects the frame. So we
+ // force a conservative GC if no Oilpan's GC has been observed in
+ // the past 5 frame navigations.
+ //
+ // We force a conservative GC not in v8ContextDisposed but in
+ // v8ContextCreated. This avoids triggering too many conservative
+ // GCs when a frame that has a lot of iframes gets detached.
+ Heap::collectGarbage(HeapPointersOnStack, GCWithoutSweep, Heap::ConservativeGC);
+ return;
+ }
+}
+
+void ThreadState::v8ContextDisposed()
+{
+ ++m_disposedV8ContextCount;
+}
+
void ThreadState::scheduleGCIfNeeded()
{
ASSERT(checkThread());
@@ -1003,6 +1025,7 @@ void ThreadState::preGC()
flushHeapDoesNotContainCacheIfNeeded();
clearHeapAges();
updatePersistentCounters();
+ m_disposedV8ContextCount = 0;
}
void ThreadState::postGC(GCType gcType)
« no previous file with comments | « third_party/WebKit/Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698