bug 803746: dom: nsWindowMemoryReporter::Init() needs to hold a ref to the reporter it's setting up (r=njn)
authorMook <mook.moz+hg@gmail.com>
Fri, 19 Oct 2012 23:18:56 -0700
changeset 111121 de544e204f13c0ed21ed7dd75ad49aabdfb7295d
parent 111024 ddca56ec6bfcec57c6739f49f5eee3796ab91e8e
child 111122 0e73daa7fc4cd2634f22021d39b0dddb575829b7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersnjn
bugs803746
milestone19.0a1
bug 803746: dom: nsWindowMemoryReporter::Init() needs to hold a ref to the reporter it's setting up (r=njn)
dom/base/nsWindowMemoryReporter.cpp
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -23,34 +23,34 @@ nsWindowMemoryReporter::nsWindowMemoryRe
 NS_IMPL_ISUPPORTS3(nsWindowMemoryReporter, nsIMemoryMultiReporter, nsIObserver,
                    nsSupportsWeakReference)
 
 /* static */
 void
 nsWindowMemoryReporter::Init()
 {
   // The memory reporter manager will own this object.
-  nsWindowMemoryReporter *windowReporter = new nsWindowMemoryReporter();
+  nsRefPtr<nsWindowMemoryReporter> windowReporter = new nsWindowMemoryReporter();
   NS_RegisterMemoryMultiReporter(windowReporter);
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   if (os) {
     // DOM_WINDOW_DESTROYED_TOPIC announces what we call window "detachment",
     // when a window's docshell is set to NULL.
     os->AddObserver(windowReporter, DOM_WINDOW_DESTROYED_TOPIC,
                     /* weakRef = */ true);
     os->AddObserver(windowReporter, "after-minimize-memory-usage",
                     /* weakRef = */ true);
   }
 
-  GhostURLsReporter *ghostMultiReporter =
+  nsRefPtr<GhostURLsReporter> ghostMultiReporter =
     new GhostURLsReporter(windowReporter);
   NS_RegisterMemoryMultiReporter(ghostMultiReporter);
 
-  NumGhostsReporter *ghostReporter =
+  nsRefPtr<NumGhostsReporter> ghostReporter =
     new NumGhostsReporter(windowReporter);
   NS_RegisterMemoryReporter(ghostReporter);
 }
 
 static already_AddRefed<nsIURI>
 GetWindowURI(nsIDOMWindow *aWindow)
 {
   nsCOMPtr<nsPIDOMWindow> pWindow = do_QueryInterface(aWindow);