Bug 1245886 - Manually stop the profiler module at the end of all tests. r=me, a=test-only
authorVictor Porof <vporof@mozilla.com>
Thu, 17 Mar 2016 08:32:22 +0100
changeset 351494 60828c17117a0b886105096e7dc1309a3f2ddecb
parent 351493 bc74c5ca31af0d92ba293c9e4a5e7b127ad06682
child 351495 a236b5c500742cf2686ae1d210e2a57ff5374269
push id15502
push userahunt@mozilla.com
push dateThu, 14 Apr 2016 20:27:48 +0000
reviewersme, test-only
bugs1245886
milestone47.0a2
Bug 1245886 - Manually stop the profiler module at the end of all tests. r=me, a=test-only
devtools/client/performance/test/head.js
--- a/devtools/client/performance/test/head.js
+++ b/devtools/client/performance/test/head.js
@@ -65,18 +65,26 @@ const key = (id, win = window) => {
 
   // By default, enable memory flame graphs for tests for now.
   // TODO: remove when we have flame charts via bug 1148663.
   Services.prefs.setBoolPref(PrefUtils.UI_ENABLE_MEMORY_FLAME_CHART, true);
 
   registerCleanupFunction(() => {
     info(`finish() was called, cleaning up...`);
     DevToolsUtils.testing = false;
+
     PrefUtils.rollbackPrefsToDefault();
     stopObservingPrefs();
 
+    // Manually stop the profiler module at the end of all tests, to hopefully
+    // avoid at least some leaks on OSX. Theoretically the module should never
+    // be active at this point. We shouldn't have to do this, but rather
+    // find and fix the leak in the module itself. Bug 1257439.
+    let nsIProfilerModule = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
+    nsIProfilerModule.StopProfiler();
+
     // Forces GC, CC and shrinking GC to get rid of disconnected docshells
     // and windows.
     Cu.forceGC();
     Cu.forceCC();
     Cu.forceShrinkingGC();
   });
 })();