Bug 747508 - Count PresContexts in about:memory; r=njn
authorNathan Froyd <froydnj@mozilla.com>
Mon, 07 May 2012 16:09:11 -0400
changeset 93616 a607eec50772ed46bc35e5b89b5bd8fe57e86dd2
parent 93615 d46217a53bf8ba204995b8073c4c7eb770131206
child 93617 5371c239bbf64c0145d3f6ba48cdcf5b965ba092
push id22658
push useremorley@mozilla.com
push dateThu, 10 May 2012 12:06:32 +0000
treeherdermozilla-central@b7b6565d12a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs747508
milestone15.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 747508 - Count PresContexts in about:memory; r=njn
content/base/src/nsDocument.cpp
dom/base/nsWindowMemoryReporter.cpp
dom/base/nsWindowMemoryReporter.h
layout/base/nsIPresShell.h
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -9693,17 +9693,18 @@ nsIDocument::DocSizeOfExcludingThis(nsWi
 {
   aWindowSizes->mDOM +=
     nsINode::SizeOfExcludingThis(aWindowSizes->mMallocSizeOf);
 
   if (mPresShell) {
     mPresShell->SizeOfIncludingThis(aWindowSizes->mMallocSizeOf,
                                     &aWindowSizes->mLayoutArenas,
                                     &aWindowSizes->mLayoutStyleSets,
-                                    &aWindowSizes->mLayoutTextRuns);
+                                    &aWindowSizes->mLayoutTextRuns,
+                                    &aWindowSizes->mLayoutPresContext);
   }
 
   // Measurement of the following members may be added later if DMD finds it
   // is worthwhile:
   // - many!
 }
 
 void
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -205,16 +205,21 @@ CollectWindowReports(nsGlobalWindow *aWi
          "Memory used by style sets within a window.");
   aWindowTotalSizes->mLayoutStyleSets += windowSizes.mLayoutStyleSets;
 
   REPORT("/layout/text-runs", windowSizes.mLayoutTextRuns,
          "Memory used for text-runs (glyph layout) in the PresShell's frame "
          "tree, within a window.");
   aWindowTotalSizes->mLayoutTextRuns += windowSizes.mLayoutTextRuns;
 
+  REPORT("/layout/pres-contexts", windowSizes.mLayoutPresContext,
+         "Memory used for the PresContext in the PresShell's frame "
+         "within a window.");
+  aWindowTotalSizes->mLayoutPresContext += windowSizes.mLayoutPresContext;
+
 #undef REPORT
 
   return NS_OK;
 }
 
 typedef nsTArray< nsRefPtr<nsGlobalWindow> > WindowArray;
 
 static
--- a/dom/base/nsWindowMemoryReporter.h
+++ b/dom/base/nsWindowMemoryReporter.h
@@ -59,16 +59,17 @@ public:
     mMallocSizeOf = aMallocSizeOf;
   }
   nsMallocSizeOfFun mMallocSizeOf;
   size_t mDOM;
   size_t mStyleSheets;
   size_t mLayoutArenas;
   size_t mLayoutStyleSets;
   size_t mLayoutTextRuns;
+  size_t mLayoutPresContext;
 };
 
 /**
  * nsWindowMemoryReporter is responsible for the 'explicit/window-objects'
  * memory reporter.
  *
  * We classify DOM window objects into one of three categories:
  *
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1216,17 +1216,18 @@ public:
   virtual void ScheduleViewManagerFlush() = 0;
   virtual void ClearMouseCaptureOnView(nsIView* aView) = 0;
   virtual bool IsVisible() = 0;
   virtual void DispatchSynthMouseMove(nsGUIEvent *aEvent, bool aFlushOnHoverChange) = 0;
 
   virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
                                    size_t *aArenasSize,
                                    size_t *aStyleSetsSize,
-                                   size_t *aTextRunsSize) const = 0;
+                                   size_t *aTextRunsSize,
+                                   size_t *aPresContextSize) const = 0;
 
   /**
    * Refresh observer management.
    */
 protected:
   virtual bool AddRefreshObserverExternal(nsARefreshObserver* aObserver,
                                             mozFlushType aFlushType);
   bool AddRefreshObserverInternal(nsARefreshObserver* aObserver,
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -8971,24 +8971,27 @@ PresShell::GetRootPresShell()
   }
   return nsnull;
 }
 
 void
 PresShell::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
                                size_t *aArenasSize,
                                size_t *aStyleSetsSize,
-                               size_t *aTextRunsSize) const
+                               size_t *aTextRunsSize,
+                               size_t *aPresContextSize) const
 {
   *aArenasSize = aMallocSizeOf(this);
   *aArenasSize += mFrameArena.SizeOfExcludingThis(aMallocSizeOf);
 
   *aStyleSetsSize = StyleSet()->SizeOfIncludingThis(aMallocSizeOf);
 
   *aTextRunsSize = SizeOfTextRuns(aMallocSizeOf);
+
+  *aPresContextSize = mPresContext->SizeOfIncludingThis(aMallocSizeOf);
 }
 
 size_t
 PresShell::SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const
 {
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   if (!rootFrame) {
     return 0;
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -817,17 +817,18 @@ private:
   PRUint32 mPresArenaAllocCount;
 #endif
 
 public:
 
   void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
                            size_t *aArenasSize,
                            size_t *aStyleSetsSize,
-                           size_t *aTextRunsSize) const;
+                           size_t *aTextRunsSize,
+                           size_t *aPresContextSize) const;
   size_t SizeOfTextRuns(nsMallocSizeOfFun aMallocSizeOf) const;
 
 protected:
   void QueryIsActive();
   nsresult UpdateImageLockingState();
 
 private:
   nscolor GetDefaultBackgroundColorToDraw();