Bug 991412: Provide static convenience method to retrieve RSS. r=njn
authorBen Kelly <ben@wanderview.com>
Mon, 07 Apr 2014 10:46:20 -0400
changeset 195804 1ad0bc421a4c1e6f199e072d8db002a75289c461
parent 195803 4f568720898413cb1e07a69de3d327ed146310c0
child 195805 03314fb9df16ebd9f652fbcaf702ea44b28ce803
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs991412
milestone31.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 991412: Provide static convenience method to retrieve RSS. r=njn
xpcom/base/nsMemoryReporterManager.cpp
xpcom/base/nsMemoryReporterManager.h
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -1493,16 +1493,28 @@ nsMemoryReporterManager::GetResidentFast
 #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS
   return ResidentFastDistinguishedAmount(aAmount);
 #else
   *aAmount = 0;
   return NS_ERROR_NOT_AVAILABLE;
 #endif
 }
 
+/*static*/
+int64_t nsMemoryReporterManager::ResidentFast()
+{
+#ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS
+    int64_t amount;
+    ResidentFastDistinguishedAmount(&amount);
+    return amount;
+#else
+    return 0;
+#endif
+}
+
 NS_IMETHODIMP
 nsMemoryReporterManager::GetHeapAllocated(int64_t* aAmount)
 {
 #ifdef HAVE_JEMALLOC_STATS
   jemalloc_stats_t stats;
   jemalloc_stats(&stats);
   *aAmount = stats.allocated;
   return NS_OK;
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -3,16 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsMemoryReporterManager_h__
 #define nsMemoryReporterManager_h__
 
 #include "nsIMemoryReporter.h"
+#include "nsITimer.h"
+#include "nsServiceManagerUtils.h"
 #include "mozilla/Mutex.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 class nsITimer;
 
 namespace mozilla {
 namespace dom {
@@ -136,16 +138,20 @@ public:
     mozilla::InfallibleAmountFn mLowMemoryEventsPhysical;
 
     mozilla::InfallibleAmountFn mGhostWindows;
 
     AmountFns() { mozilla::PodZero(this); }
   };
   AmountFns mAmountFns;
 
+  // Convenience function to get RSS easily from other code.  This is useful
+  // when debugging transient memory spikes with printf instrumentation.
+  static int64_t ResidentFast();
+
   // Functions that measure per-tab memory consumption.
   struct SizeOfTabFns
   {
     mozilla::JSSizeOfTabFn    mJS;
     mozilla::NonJSSizeOfTabFn mNonJS;
 
     SizeOfTabFns()
     {