hooked up Leak Detector contextual menu.

This commit is contained in:
beard%netscape.com 2000-09-02 08:23:50 +00:00
Родитель e209c2abb5
Коммит b7a03a8ba1
3 изменённых файлов: 44 добавлений и 22 удалений

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

@ -1529,31 +1529,42 @@ function dumpExpr( expr ) {
dump( expr+"="+eval(expr)+"\n" );
}
var leakDetector = null;
function getLeakDetector()
// Initialize the LeakDetector class.
function LeakDetector(verbose)
{
leakDetector = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector");
if (leakDetector == null) {
dump("Could not create leak detector, leak detection probably\n");
dump("not compiled into this browser\n");
}
this.verbose = verbose;
try {
this.vtable = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector");
} catch (err) {
}
}
var leakDetector = new LeakDetector(false);
// Dumps current set of memory leaks.
function dumpMemoryLeaks() {
if (leakDetector == null)
getLeakDetector();
if (leakDetector != null)
leakDetector.dumpLeaks();
function dumpMemoryLeaks()
{
leakDetector.vtable.dumpLeaks();
}
function traceObject(object)
// Traces all objects reachable from the chrome document.
function traceChrome()
{
if (leakDetector == null)
getLeakDetector();
if (leakDetector != null)
leakDetector.traceObject(object);
leakDetector.vtable.traceObject(document, leakDetector.verbose);
}
// Traces all objects reachable from the content document.
function traceDocument()
{
// keep the chrome document out of the dump.
leakDetector.vtable.markObject(document, true);
leakDetector.vtable.traceObject(window._content, leakDetector.verbose);
leakDetector.vtable.markObject(document, false);
}
// Controls whether or not we do verbose tracing.
function traceVerbose(verbose)
{
leakDetector.verbose = (verbose == "true");
}
var consoleListener = {

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

@ -524,8 +524,17 @@ oncommand="goPreferences('pref-themes.xul','chrome://communicator/content/pref/p
<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="dumpMemoryLeaks();"/>
<menuitem value="&BloatTraceCmd.label;" oncommand="traceObject(document);"/>
<menuseparator />
<menu value="Leak Detector">
<menupopup>
<menuitem value="&LeaksDumpLeaksCmd.label;" oncommand="dumpMemoryLeaks();"/>
<menuitem value="&LeaksTraceChromeCmd.label;" oncommand="traceChrome();"/>
<menuitem value="&LeaksTraceDocumentCmd.label;" oncommand="traceDocument();"/>
<menuitem value="&LeaksTraceVerboseCmd.label;" oncommand="traceVerbose(this.getAttribute('checked'))" type="checkbox" checked="false"/>
</menupopup>
</menu>
</menupopup>
</menu>
</menubar>

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

@ -300,8 +300,10 @@
<!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">
<!ENTITY BloatTraceCmd.label "Bloat: Trace Document">
<!ENTITY LeaksDumpLeaksCmd.label "Dump Memory Leaks">
<!ENTITY LeaksTraceChromeCmd.label "Trace Chrome">
<!ENTITY LeaksTraceDocumentCmd.label "Trace Document">
<!ENTITY LeaksTraceVerboseCmd.label "Verbose">
<!ENTITY URIDispatchingCmd.label "URI Dispatching">
<!ENTITY URIDispatchingEnableCmd.label "Enable Dispatching">
<!ENTITY URIDispatchingDisableCmd.label "Disable Dispatching">