From 2f804162559ce1665563b60c4ea63b547411c929 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Tue, 22 Feb 2000 13:25:20 +0000 Subject: [PATCH] Bug 28413. Correct computation of total leaks. r=warren@netscape.com a=rickg@netscape.com --- xpcom/base/nsTraceRefcnt.cpp | 9 ++++++++- xpcom/base/nsTraceRefcntImpl.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xpcom/base/nsTraceRefcnt.cpp b/xpcom/base/nsTraceRefcnt.cpp index 2d9e1125220..1bacfaaf590 100644 --- a/xpcom/base/nsTraceRefcnt.cpp +++ b/xpcom/base/nsTraceRefcnt.cpp @@ -137,6 +137,7 @@ public: : mClassName(className), mClassSize(classSize) { Clear(&mNewStats); Clear(&mAllStats); + mTotalLeaked = 0; } ~BloatEntry() {} @@ -243,6 +244,9 @@ public: total->mAllStats.mObjsOutstandingSquared += mNewStats.mObjsOutstandingSquared + mAllStats.mObjsOutstandingSquared; PRInt32 count = (mNewStats.mCreates + mAllStats.mCreates); total->mClassSize += mClassSize * count; // adjust for average in DumpTotal + total->mTotalLeaked += mClassSize * + ((mNewStats.mCreates + mAllStats.mCreates) + -(mNewStats.mDestroys + mAllStats.mDestroys)); } nsresult DumpTotal(PRUint32 nClasses, FILE* out) { @@ -314,7 +318,9 @@ public: fprintf(out, "%4d %-20.20s %8d %8d %8d %8d (%8.2f +/- %8.2f) %8d %8d (%8.2f +/- %8.2f)\n", i+1, mClassName, (PRInt32)mClassSize, - (PRInt32)((stats->mCreates - stats->mDestroys) * mClassSize), + (nsCRT::strcmp(mClassName, "TOTAL")) + ?(PRInt32)((stats->mCreates - stats->mDestroys) * mClassSize) + :mTotalLeaked, stats->mCreates, (stats->mCreates - stats->mDestroys), meanObjs, @@ -330,6 +336,7 @@ public: protected: const char* mClassName; double mClassSize; // this is stored as a double because of the way we compute the avg class size for total bloat + PRInt32 mTotalLeaked; // used only for TOTAL entry nsTraceRefcntStats mNewStats; nsTraceRefcntStats mAllStats; }; diff --git a/xpcom/base/nsTraceRefcntImpl.cpp b/xpcom/base/nsTraceRefcntImpl.cpp index 2d9e1125220..1bacfaaf590 100644 --- a/xpcom/base/nsTraceRefcntImpl.cpp +++ b/xpcom/base/nsTraceRefcntImpl.cpp @@ -137,6 +137,7 @@ public: : mClassName(className), mClassSize(classSize) { Clear(&mNewStats); Clear(&mAllStats); + mTotalLeaked = 0; } ~BloatEntry() {} @@ -243,6 +244,9 @@ public: total->mAllStats.mObjsOutstandingSquared += mNewStats.mObjsOutstandingSquared + mAllStats.mObjsOutstandingSquared; PRInt32 count = (mNewStats.mCreates + mAllStats.mCreates); total->mClassSize += mClassSize * count; // adjust for average in DumpTotal + total->mTotalLeaked += mClassSize * + ((mNewStats.mCreates + mAllStats.mCreates) + -(mNewStats.mDestroys + mAllStats.mDestroys)); } nsresult DumpTotal(PRUint32 nClasses, FILE* out) { @@ -314,7 +318,9 @@ public: fprintf(out, "%4d %-20.20s %8d %8d %8d %8d (%8.2f +/- %8.2f) %8d %8d (%8.2f +/- %8.2f)\n", i+1, mClassName, (PRInt32)mClassSize, - (PRInt32)((stats->mCreates - stats->mDestroys) * mClassSize), + (nsCRT::strcmp(mClassName, "TOTAL")) + ?(PRInt32)((stats->mCreates - stats->mDestroys) * mClassSize) + :mTotalLeaked, stats->mCreates, (stats->mCreates - stats->mDestroys), meanObjs, @@ -330,6 +336,7 @@ public: protected: const char* mClassName; double mClassSize; // this is stored as a double because of the way we compute the avg class size for total bloat + PRInt32 mTotalLeaked; // used only for TOTAL entry nsTraceRefcntStats mNewStats; nsTraceRefcntStats mAllStats; };