summaryrefslogtreecommitdiffstats
path: root/content/shell/renderer/gc_controller.cc
diff options
context:
space:
mode:
authorharaken@chromium.org <haraken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 08:25:15 +0000
committerharaken@chromium.org <haraken@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-05 08:25:15 +0000
commitc7d9004083f26ff05cde7a3d94075cf309f42b5d (patch)
tree2cb2d7ee38b4f261c10bb529afe2ad8dca601b4d /content/shell/renderer/gc_controller.cc
parent909e9b050c740980a05d6073496ecd7bd13ebe57 (diff)
downloadchromium_src-c7d9004083f26ff05cde7a3d94075cf309f42b5d.zip
chromium_src-c7d9004083f26ff05cde7a3d94075cf309f42b5d.tar.gz
chromium_src-c7d9004083f26ff05cde7a3d94075cf309f42b5d.tar.bz2
Implement GCController::CollectAll
One GC cycle is not enough to collect DOM wrappers. To test that all DOM wrappers are reclaimed, this CL adds a function that triggers multiple GC cycles. BUG=307614 Review URL: https://codereview.chromium.org/153803002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/renderer/gc_controller.cc')
-rw-r--r--content/shell/renderer/gc_controller.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/content/shell/renderer/gc_controller.cc b/content/shell/renderer/gc_controller.cc
index ad4fa04..f8d3b09 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);