Temporarily land patch to dump leaked nsStandardURL objects at shutdown, to give us more insight into the portion of the random orange that is random leaks. a=josh for CLOSED TREE

This commit is contained in:
L. David Baron 2009-05-08 14:26:33 -07:00
Родитель ea0539e764
Коммит 812a8ebd1a
2 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -55,6 +55,7 @@
#include "prlog.h"
#include "nsAutoPtr.h"
#include "nsIProgrammingLanguage.h"
#include "nsVoidArray.h"
static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID);
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
@ -269,6 +270,10 @@ nsSegmentEncoder::InitUnicodeEncoder()
// nsStandardURL <public>
//----------------------------------------------------------------------------
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
static PRCList gAllURLs;
#endif
nsStandardURL::nsStandardURL(PRBool aSupportsFileURL)
: mDefaultPort(-1)
, mPort(-1)
@ -293,6 +298,10 @@ nsStandardURL::nsStandardURL(PRBool aSupportsFileURL)
// default parser in case nsIStandardURL::Init is never called
mParser = net_GetStdURLParser();
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PR_APPEND_LINK(&mDebugCList, &gAllURLs);
#endif
}
nsStandardURL::~nsStandardURL()
@ -300,8 +309,24 @@ nsStandardURL::~nsStandardURL()
LOG(("Destroying nsStandardURL @%p\n", this));
CRTFREEIF(mHostA);
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PR_REMOVE_LINK(&mDebugCList);
#endif
}
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
static void DumpLeakedURLs()
{
if (!PR_CLIST_IS_EMPTY(&gAllURLs)) {
printf("Leaked URLs:\n");
for (PRCList *l = PR_LIST_HEAD(&gAllURLs); l != &gAllURLs; l = PR_NEXT_LINK(l)) {
nsStandardURL *url = reinterpret_cast<nsStandardURL*>(reinterpret_cast<char*>(l) - offsetof(nsStandardURL, mDebugCList));
url->PrintSpec();
}
}
}
#endif
void
nsStandardURL::InitGlobalObjects()
{
@ -315,6 +340,11 @@ nsStandardURL::InitGlobalObjects()
PrefsChanged(prefBranch, nsnull);
}
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PR_INIT_CLIST(&gAllURLs);
atexit(DumpLeakedURLs);
#endif
}
void

Просмотреть файл

@ -53,6 +53,9 @@
#include "nsCOMPtr.h"
#include "nsURLHelper.h"
#include "nsIClassInfo.h"
#include "prclist.h"
#define DEBUG_DUMP_URLS_AT_SHUTDOWN
class nsIBinaryInputStream;
class nsIBinaryOutputStream;
@ -271,6 +274,12 @@ private:
static PRBool gEscapeUTF8;
static PRBool gAlwaysEncodeInUTF8;
static PRBool gEncodeQueryInUTF8;
public:
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
PRCList mDebugCList;
void PrintSpec() const { printf(" %s\n", mSpec.get()); }
#endif
};
#define NS_THIS_STANDARDURL_IMPL_CID \