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

Unified Diff: content/shell/renderer/gc_controller.cc

Issue 153803002: Implement GCController::CollectAll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « content/shell/renderer/gc_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/gc_controller.cc
diff --git a/content/shell/renderer/gc_controller.cc b/content/shell/renderer/gc_controller.cc
index ad4fa0419e2c41e50f229a3cd030030068cfcdf8..f8d3b0909c54cb16ce16a331724bc831a5e87eba 100644
--- a/content/shell/renderer/gc_controller.cc
+++ b/content/shell/renderer/gc_controller.cc
@@ -39,6 +39,7 @@ gin::ObjectTemplateBuilder GCController::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin::Wrappable<GCController>::GetObjectTemplateBuilder(isolate)
.SetMethod("collect", &GCController::Collect)
+ .SetMethod("collectAll", &GCController::CollectAll)
.SetMethod("minorCollect", &GCController::MinorCollect);
}
@@ -47,6 +48,20 @@ void GCController::Collect(const gin::Arguments& args) {
v8::Isolate::kFullGarbageCollection);
}
+void GCController::CollectAll(const gin::Arguments& args) {
+ // In order to collect a DOM wrapper, two GC cycles are needed.
+ // In the first GC cycle, a weak callback of the DOM wrapper is called back
+ // and the weak callback disposes a persistent handle to the DOM wrapper.
+ // In the second GC cycle, the DOM wrapper is reclaimed.
+ // Given that two GC cycles are needed to collect one DOM wrapper,
+ // more than two GC cycles are needed to collect all DOM wrappers
+ // that are chained. Seven GC cycles look enough in most tests.
+ for (int i = 0; i < 7; i++) {
+ args.isolate()->RequestGarbageCollectionForTesting(
+ v8::Isolate::kFullGarbageCollection);
+ }
+}
+
void GCController::MinorCollect(const gin::Arguments& args) {
args.isolate()->RequestGarbageCollectionForTesting(
v8::Isolate::kMinorGarbageCollection);
« no previous file with comments | « content/shell/renderer/gc_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698