added support for "about:bloat?leaks". bug=15906,r=warren

This commit is contained in:
beard%netscape.com 1999-10-14 01:56:49 +00:00
parent 5df2518a9c
commit 67ade3a167
5 changed files with 28 additions and 0 deletions

View File

@ -27,6 +27,12 @@
#include "nsCOMPtr.h"
#include "nsIFileStream.h"
#ifdef XP_MAC
extern "C" void GC_gcollect(void);
#else
static void GC_gcollect() {}
#endif
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
NS_IMPL_ISUPPORTS(nsAboutBloat, NS_GET_IID(nsIAboutModule));
@ -45,6 +51,7 @@ nsAboutBloat::NewChannel(const char *verb,
nsTraceRefcnt::StatisticsType statType = nsTraceRefcnt::ALL_STATS;
PRBool clear = PR_FALSE;
PRBool leaks = PR_FALSE;
nsCAutoString p(path);
PRInt32 pos = p.Find("?");
@ -55,6 +62,8 @@ nsAboutBloat::NewChannel(const char *verb,
statType = nsTraceRefcnt::NEW_STATS;
else if (param.Equals("clear"))
clear = PR_TRUE;
else if (param.Equals("leaks"))
leaks = PR_TRUE;
}
nsCOMPtr<nsIInputStream> inStr;
@ -72,6 +81,21 @@ nsAboutBloat::NewChannel(const char *verb,
inStr = do_QueryInterface(s, &rv);
if (NS_FAILED(rv)) return rv;
}
else
if (leaks) {
// dump the current set of leaks.
GC_gcollect();
nsCOMPtr<nsISupports> s;
const char* msg = "Memory leaks dumped.";
rv = NS_NewStringInputStream(getter_AddRefs(s), msg);
if (NS_FAILED(rv)) return rv;
size = nsCRT::strlen(msg);
inStr = do_QueryInterface(s, &rv);
if (NS_FAILED(rv)) return rv;
}
else {
nsSpecialSystemDirectory file(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
file += "bloatlogs";

View File

@ -557,6 +557,7 @@ Contributor(s): ______________________________________. -->
<menuitem value="&BloatDumpNewCmd.label;" oncommand="window.content.location.href='about:bloat?new'"/>
<menuitem value="&BloatDumpAllCmd.label;" oncommand="window.content.location.href='about:bloat'"/>
<menuitem value="&BloatClearCmd.label;" oncommand="window.content.location.href='about:bloat?clear'"/>
<menuitem value="&BloatLeaksCmd.label;" oncommand="window.content.location.href='about:bloat?leaks'"/>
</menupopup>
</menu>
<spring flex="100%"/>

View File

@ -268,6 +268,7 @@
<!ENTITY BloatDumpNewCmd.label "Bloat: Dump New Stats">
<!ENTITY BloatDumpAllCmd.label "Bloat: Dump All Stats">
<!ENTITY BloatClearCmd.label "Bloat: Clear Stats">
<!ENTITY BloatLeaksCmd.label "Bloat: Dump Memory Leaks">
<!-- LOCALIZATION NOTE END : DO not localize the entities above; QA -->

View File

@ -557,6 +557,7 @@ Contributor(s): ______________________________________. -->
<menuitem value="&BloatDumpNewCmd.label;" oncommand="window.content.location.href='about:bloat?new'"/>
<menuitem value="&BloatDumpAllCmd.label;" oncommand="window.content.location.href='about:bloat'"/>
<menuitem value="&BloatClearCmd.label;" oncommand="window.content.location.href='about:bloat?clear'"/>
<menuitem value="&BloatLeaksCmd.label;" oncommand="window.content.location.href='about:bloat?leaks'"/>
</menupopup>
</menu>
<spring flex="100%"/>

View File

@ -268,6 +268,7 @@
<!ENTITY BloatDumpNewCmd.label "Bloat: Dump New Stats">
<!ENTITY BloatDumpAllCmd.label "Bloat: Dump All Stats">
<!ENTITY BloatClearCmd.label "Bloat: Clear Stats">
<!ENTITY BloatLeaksCmd.label "Bloat: Dump Memory Leaks">
<!-- LOCALIZATION NOTE END : DO not localize the entities above; QA -->