Bug 1055151 - Add tests to cap devtools memory footprint. r=ochameau
authorJan Keromnes <janx@linux.com>
Fri, 12 Sep 2014 10:32:12 -0700
changeset 205153 f79c92446b515e2043c821453c30d3c6ac197e43
parent 205152 76818efae28ee6d16735d0ae3058e91131360fb2
child 205154 adba5a9030d360087468dbe8b1da55eaad09827a
push id49106
push userphilringnalda@gmail.com
push dateSat, 13 Sep 2014 17:12:34 +0000
treeherdermozilla-inbound@ab04d0f2665f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1055151
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1055151 - Add tests to cap devtools memory footprint. r=ochameau
toolkit/devtools/server/tests/unit/test_memory_footprint.js
toolkit/devtools/server/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/devtools/server/tests/unit/test_memory_footprint.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var gClient;
+var gMgr;
+var gRefMemory;
+
+function run_test() {
+  gMgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
+  Cu.forceGC();
+  gRefMemory = gMgr.residentUnique;
+
+  add_test(init_server);
+  add_test(add_browser_actors);
+  add_test(connect_client);
+  add_test(list_tabs);
+  add_test(close_client);
+  run_next_test();
+}
+
+function check_footprint(step, max) {
+  var footprint = (gMgr.residentUnique - gRefMemory) / 1024;
+  ok(footprint < max, "Footprint after " + step + " is " + footprint + " kB (should be less than " + max + " kB).");
+  run_next_test();
+}
+
+function init_server() {
+  DebuggerServer.init(function () { return true; });
+  check_footprint("DebuggerServer.init()", 500);
+}
+
+function add_browser_actors() {
+  DebuggerServer.addBrowserActors();
+  check_footprint("DebuggerServer.addBrowserActors()", 12000);
+}
+
+function connect_client() {
+  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  gClient.connect(function onConnect() {
+    check_footprint("DebuggerClient.connect()", 12500);
+  });
+}
+
+function list_tabs() {
+  gClient.listTabs(function onListTabs(aResponse) {
+    check_footprint("DebuggerClient.listTabs()", 13000);
+  });
+}
+
+function close_client() {
+  gClient.close(run_next_test);
+}
--- a/toolkit/devtools/server/tests/unit/xpcshell.ini
+++ b/toolkit/devtools/server/tests/unit/xpcshell.ini
@@ -204,8 +204,12 @@ reason = bug 820380
 reason = bug 937197
 [test_layout-reflows-observer.js]
 [test_protocolSpec.js]
 [test_registerClient.js]
 [test_client_request.js]
 [test_monitor_actor.js]
 [test_symbols-01.js]
 [test_symbols-02.js]
+[test_memory_footprint.js]
+run-sequentially = measure memory, has to be run solo
+skip-if = os != 'linux' || debug || asan
+reason = bug 1014071