2011-06-29 04:01:07 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2012-02-23 18:43:33 -08:00
|
|
|
#include "nsWindowMemoryReporter.h"
|
2011-06-29 04:06:43 -07:00
|
|
|
#include "nsGlobalWindow.h"
|
2012-04-02 19:28:04 -07:00
|
|
|
#include "nsIEffectiveTLDService.h"
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsPrintfCString.h"
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
using namespace mozilla;
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2012-02-23 18:43:33 -08:00
|
|
|
nsWindowMemoryReporter::nsWindowMemoryReporter()
|
2012-04-02 19:28:04 -07:00
|
|
|
: mCheckForGhostWindowsCallbackPending(false)
|
2011-06-29 04:01:07 -07:00
|
|
|
{
|
2012-04-02 19:28:04 -07:00
|
|
|
mDetachedWindows.Init();
|
2011-06-29 04:01:07 -07:00
|
|
|
}
|
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
NS_IMPL_ISUPPORTS3(nsWindowMemoryReporter, nsIMemoryMultiReporter, nsIObserver,
|
|
|
|
nsSupportsWeakReference)
|
2011-06-29 04:01:07 -07:00
|
|
|
|
|
|
|
/* static */
|
|
|
|
void
|
2012-02-23 18:43:33 -08:00
|
|
|
nsWindowMemoryReporter::Init()
|
2011-06-29 04:01:07 -07:00
|
|
|
{
|
2012-04-02 19:28:05 -07:00
|
|
|
// The memory reporter manager will own this object.
|
|
|
|
nsWindowMemoryReporter *windowReporter = new nsWindowMemoryReporter();
|
|
|
|
NS_RegisterMemoryMultiReporter(windowReporter);
|
2012-04-02 19:28:04 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
|
|
|
if (os) {
|
|
|
|
// DOM_WINDOW_DESTROYED_TOPIC announces what we call window "detachment",
|
|
|
|
// when a window's docshell is set to NULL.
|
2012-04-02 19:28:05 -07:00
|
|
|
os->AddObserver(windowReporter, DOM_WINDOW_DESTROYED_TOPIC,
|
|
|
|
/* weakRef = */ true);
|
|
|
|
os->AddObserver(windowReporter, "after-minimize-memory-usage",
|
|
|
|
/* weakRef = */ true);
|
2012-04-02 19:28:04 -07:00
|
|
|
}
|
2012-04-02 19:28:05 -07:00
|
|
|
|
2012-04-02 19:28:13 -07:00
|
|
|
GhostURLsReporter *ghostMultiReporter =
|
|
|
|
new GhostURLsReporter(windowReporter);
|
|
|
|
NS_RegisterMemoryMultiReporter(ghostMultiReporter);
|
|
|
|
|
|
|
|
NumGhostsReporter *ghostReporter =
|
|
|
|
new NumGhostsReporter(windowReporter);
|
|
|
|
NS_RegisterMemoryReporter(ghostReporter);
|
2011-06-29 04:01:07 -07:00
|
|
|
}
|
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
static already_AddRefed<nsIURI>
|
|
|
|
GetWindowURI(nsIDOMWindow *aWindow)
|
2011-06-29 04:01:07 -07:00
|
|
|
{
|
2012-04-02 19:28:04 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> pWindow = do_QueryInterface(aWindow);
|
|
|
|
NS_ENSURE_TRUE(pWindow, NULL);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc = do_QueryInterface(pWindow->GetExtantDocument());
|
2011-12-08 21:42:20 -08:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2011-12-08 21:42:20 -08:00
|
|
|
if (doc) {
|
|
|
|
uri = doc->GetDocumentURI();
|
|
|
|
}
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2011-12-08 21:42:20 -08:00
|
|
|
if (!uri) {
|
2012-04-02 19:28:04 -07:00
|
|
|
nsCOMPtr<nsIScriptObjectPrincipal> scriptObjPrincipal =
|
|
|
|
do_QueryInterface(aWindow);
|
|
|
|
NS_ENSURE_TRUE(scriptObjPrincipal, NULL);
|
|
|
|
|
|
|
|
nsIPrincipal *principal = scriptObjPrincipal->GetPrincipal();
|
2011-06-29 04:01:07 -07:00
|
|
|
|
2011-12-08 21:42:20 -08:00
|
|
|
if (principal) {
|
|
|
|
principal->GetURI(getter_AddRefs(uri));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
return uri.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURI> uri = GetWindowURI(aWindow);
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
if (uri) {
|
|
|
|
nsCString spec;
|
|
|
|
uri->GetSpec(spec);
|
2011-12-08 21:42:20 -08:00
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
// A hack: replace forward slashes with '\\' so they aren't
|
|
|
|
// treated as path separators. Users of the reporters
|
|
|
|
// (such as about:memory) have to undo this change.
|
|
|
|
spec.ReplaceChar('/', '\\');
|
2011-12-08 21:42:20 -08:00
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
aStr += spec;
|
|
|
|
} else {
|
2012-04-02 19:28:04 -07:00
|
|
|
// If we're unable to find a URI, we're dealing with a chrome window with
|
|
|
|
// no document in it (or somesuch), so we call this a "system window".
|
2012-03-12 23:00:18 -07:00
|
|
|
aStr += NS_LITERAL_CSTRING("[system]");
|
|
|
|
}
|
2011-06-29 04:01:07 -07:00
|
|
|
}
|
2011-06-29 04:06:43 -07:00
|
|
|
|
2012-02-21 07:10:11 -08:00
|
|
|
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(DOMStyleMallocSizeOf, "windows")
|
2011-12-08 21:42:20 -08:00
|
|
|
|
2012-03-04 15:26:30 -08:00
|
|
|
static nsresult
|
2012-01-02 18:19:14 -08:00
|
|
|
CollectWindowReports(nsGlobalWindow *aWindow,
|
2012-02-21 07:10:11 -08:00
|
|
|
nsWindowSizes *aWindowTotalSizes,
|
2012-04-02 19:28:04 -07:00
|
|
|
nsTHashtable<nsUint64HashKey> *aGhostWindowIDs,
|
2012-01-02 18:19:14 -08:00
|
|
|
nsIMemoryMultiReporterCallback *aCb,
|
|
|
|
nsISupports *aClosure)
|
|
|
|
{
|
2012-04-02 12:44:31 -07:00
|
|
|
nsCAutoString windowPath("explicit/window-objects/");
|
2012-04-02 07:37:04 -07:00
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
// Avoid calling aWindow->GetTop() if there's no outer window. It will work
|
|
|
|
// just fine, but will spew a lot of warnings.
|
|
|
|
nsGlobalWindow *top = NULL;
|
|
|
|
if (aWindow->GetOuterWindow()) {
|
|
|
|
// Our window should have a null top iff it has a null docshell.
|
|
|
|
MOZ_ASSERT(!!aWindow->GetTop() == !!aWindow->GetDocShell());
|
|
|
|
top = aWindow->GetTop();
|
|
|
|
}
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
if (top) {
|
2012-04-02 19:28:04 -07:00
|
|
|
windowPath += NS_LITERAL_CSTRING("top(");
|
2012-03-12 23:00:18 -07:00
|
|
|
AppendWindowURI(top, windowPath);
|
|
|
|
windowPath += NS_LITERAL_CSTRING(", id=");
|
|
|
|
windowPath.AppendInt(top->WindowID());
|
2012-04-02 19:28:04 -07:00
|
|
|
windowPath += NS_LITERAL_CSTRING(")/");
|
2011-12-08 21:42:20 -08:00
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
windowPath += aWindow->IsFrozen() ? NS_LITERAL_CSTRING("cached/")
|
|
|
|
: NS_LITERAL_CSTRING("active/");
|
2011-12-08 21:42:20 -08:00
|
|
|
} else {
|
2012-04-02 19:28:04 -07:00
|
|
|
if (aGhostWindowIDs->Contains(aWindow->WindowID())) {
|
|
|
|
windowPath += NS_LITERAL_CSTRING("top(none)/ghost/");
|
|
|
|
} else {
|
|
|
|
windowPath += NS_LITERAL_CSTRING("top(none)/detached/");
|
|
|
|
}
|
2011-12-08 21:42:20 -08:00
|
|
|
}
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
windowPath += NS_LITERAL_CSTRING("window(");
|
|
|
|
AppendWindowURI(aWindow, windowPath);
|
|
|
|
windowPath += NS_LITERAL_CSTRING(")");
|
|
|
|
|
|
|
|
#define REPORT(_pathTail, _amount, _desc) \
|
2012-02-21 07:10:11 -08:00
|
|
|
do { \
|
|
|
|
if (_amount > 0) { \
|
2012-03-12 23:00:18 -07:00
|
|
|
nsCAutoString path(windowPath); \
|
|
|
|
path += _pathTail; \
|
2012-03-04 15:26:30 -08:00
|
|
|
nsresult rv; \
|
|
|
|
rv = aCb->Callback(EmptyCString(), path, nsIMemoryReporter::KIND_HEAP,\
|
2012-02-21 07:10:11 -08:00
|
|
|
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
|
|
|
NS_LITERAL_CSTRING(_desc), aClosure); \
|
2012-03-04 15:26:30 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv); \
|
2012-02-21 07:10:11 -08:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
nsWindowSizes windowSizes(DOMStyleMallocSizeOf);
|
|
|
|
aWindow->SizeOfIncludingThis(&windowSizes);
|
|
|
|
|
2012-06-05 07:49:48 -07:00
|
|
|
REPORT("/dom/other", windowSizes.mDOMOther,
|
|
|
|
"Memory used by a window's DOM, excluding element, text, CDATA, "
|
|
|
|
"and comment nodes.");
|
|
|
|
aWindowTotalSizes->mDOMOther += windowSizes.mDOMOther;
|
|
|
|
|
|
|
|
REPORT("/dom/element-nodes", windowSizes.mDOMElementNodes,
|
|
|
|
"Memory used by the element nodes in a window's DOM.");
|
|
|
|
aWindowTotalSizes->mDOMElementNodes += windowSizes.mDOMElementNodes;
|
|
|
|
|
|
|
|
REPORT("/dom/text-nodes", windowSizes.mDOMTextNodes,
|
|
|
|
"Memory used by the text nodes in a window's DOM.");
|
|
|
|
aWindowTotalSizes->mDOMTextNodes += windowSizes.mDOMTextNodes;
|
|
|
|
|
|
|
|
REPORT("/dom/cdata-nodes", windowSizes.mDOMCDATANodes,
|
|
|
|
"Memory used by the CDATA nodes in a window's DOM.");
|
|
|
|
aWindowTotalSizes->mDOMCDATANodes += windowSizes.mDOMCDATANodes;
|
|
|
|
|
|
|
|
REPORT("/dom/comment-nodes", windowSizes.mDOMCommentNodes,
|
|
|
|
"Memory used by the comment nodes in a window's DOM.");
|
|
|
|
aWindowTotalSizes->mDOMCommentNodes += windowSizes.mDOMCommentNodes;
|
2012-02-21 07:10:11 -08:00
|
|
|
|
2012-06-14 21:10:08 -07:00
|
|
|
REPORT("/property-tables",
|
|
|
|
windowSizes.mPropertyTables,
|
|
|
|
"Memory used for the property tables within a window.");
|
|
|
|
aWindowTotalSizes->mPropertyTables += windowSizes.mPropertyTables;
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
REPORT("/style-sheets", windowSizes.mStyleSheets,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used by style sheets within a window.");
|
|
|
|
aWindowTotalSizes->mStyleSheets += windowSizes.mStyleSheets;
|
|
|
|
|
2012-06-06 10:29:16 -07:00
|
|
|
REPORT("/layout/pres-shell", windowSizes.mLayoutPresShell,
|
|
|
|
"Memory used by layout's PresShell, along with any structures "
|
|
|
|
"allocated in its arena and not measured elsewhere, "
|
|
|
|
"within a window.");
|
|
|
|
aWindowTotalSizes->mLayoutPresShell += windowSizes.mLayoutPresShell;
|
2012-02-21 07:10:11 -08:00
|
|
|
|
2012-06-06 10:35:40 -07:00
|
|
|
REPORT("/layout/line-boxes", windowSizes.mArenaStats.mLineBoxes,
|
|
|
|
"Memory used by line boxes within a window.");
|
|
|
|
aWindowTotalSizes->mArenaStats.mLineBoxes
|
|
|
|
+= windowSizes.mArenaStats.mLineBoxes;
|
|
|
|
|
|
|
|
REPORT("/layout/rule-nodes", windowSizes.mArenaStats.mRuleNodes,
|
|
|
|
"Memory used by CSS rule nodes within a window.");
|
|
|
|
aWindowTotalSizes->mArenaStats.mRuleNodes
|
|
|
|
+= windowSizes.mArenaStats.mRuleNodes;
|
|
|
|
|
|
|
|
REPORT("/layout/style-contexts", windowSizes.mArenaStats.mStyleContexts,
|
|
|
|
"Memory used by style contexts within a window.");
|
|
|
|
aWindowTotalSizes->mArenaStats.mStyleContexts
|
|
|
|
+= windowSizes.mArenaStats.mStyleContexts;
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
REPORT("/layout/style-sets", windowSizes.mLayoutStyleSets,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used by style sets within a window.");
|
|
|
|
aWindowTotalSizes->mLayoutStyleSets += windowSizes.mLayoutStyleSets;
|
|
|
|
|
2012-03-12 23:00:18 -07:00
|
|
|
REPORT("/layout/text-runs", windowSizes.mLayoutTextRuns,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used for text-runs (glyph layout) in the PresShell's frame "
|
|
|
|
"tree, within a window.");
|
|
|
|
aWindowTotalSizes->mLayoutTextRuns += windowSizes.mLayoutTextRuns;
|
|
|
|
|
2012-05-07 13:09:11 -07:00
|
|
|
REPORT("/layout/pres-contexts", windowSizes.mLayoutPresContext,
|
|
|
|
"Memory used for the PresContext in the PresShell's frame "
|
|
|
|
"within a window.");
|
|
|
|
aWindowTotalSizes->mLayoutPresContext += windowSizes.mLayoutPresContext;
|
|
|
|
|
2012-06-06 10:29:16 -07:00
|
|
|
// There are many different kinds of frames, but it is very likely
|
|
|
|
// that only a few matter. Implement a cutoff so we don't bloat
|
|
|
|
// about:memory with many uninteresting entries.
|
|
|
|
static const size_t FRAME_SUNDRIES_THRESHOLD = 8192;
|
|
|
|
size_t frameSundriesSize = 0;
|
|
|
|
#define FRAME_ID(classname) \
|
|
|
|
{ \
|
|
|
|
size_t frameSize \
|
|
|
|
= windowSizes.mArenaStats.FRAME_ID_STAT_FIELD(classname); \
|
|
|
|
if (frameSize < FRAME_SUNDRIES_THRESHOLD) { \
|
|
|
|
frameSundriesSize += frameSize; \
|
|
|
|
} else { \
|
|
|
|
REPORT("/layout/frames/" # classname, frameSize, \
|
|
|
|
"Memory used by frames of " \
|
|
|
|
"type " #classname " within a window."); \
|
|
|
|
aWindowTotalSizes->mArenaStats.FRAME_ID_STAT_FIELD(classname) \
|
|
|
|
+= frameSize; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#include "nsFrameIdList.h"
|
|
|
|
#undef FRAME_ID
|
|
|
|
|
|
|
|
if (frameSundriesSize > 0) {
|
|
|
|
REPORT("/layout/frames/sundries", frameSundriesSize,
|
|
|
|
"The sum of all memory used by frames which were too small "
|
|
|
|
"to be shown individually.");
|
|
|
|
}
|
|
|
|
|
2012-02-21 07:10:11 -08:00
|
|
|
#undef REPORT
|
2012-03-04 15:26:30 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
2011-06-29 05:29:29 -07:00
|
|
|
}
|
|
|
|
|
2011-12-08 21:42:20 -08:00
|
|
|
typedef nsTArray< nsRefPtr<nsGlobalWindow> > WindowArray;
|
|
|
|
|
2011-06-29 04:06:43 -07:00
|
|
|
static
|
|
|
|
PLDHashOperator
|
2011-12-08 21:42:20 -08:00
|
|
|
GetWindows(const PRUint64& aId, nsGlobalWindow*& aWindow, void* aClosure)
|
2011-06-29 04:06:43 -07:00
|
|
|
{
|
2011-12-08 21:42:20 -08:00
|
|
|
((WindowArray *)aClosure)->AppendElement(aWindow);
|
|
|
|
|
2011-06-29 04:06:43 -07:00
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
2012-02-06 17:02:59 -08:00
|
|
|
NS_IMETHODIMP
|
2012-02-23 18:43:33 -08:00
|
|
|
nsWindowMemoryReporter::GetName(nsACString &aName)
|
2012-02-06 17:02:59 -08:00
|
|
|
{
|
2012-02-21 07:10:11 -08:00
|
|
|
aName.AssignLiteral("window-objects");
|
2012-02-06 17:02:59 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-29 04:01:07 -07:00
|
|
|
NS_IMETHODIMP
|
2012-02-23 18:43:33 -08:00
|
|
|
nsWindowMemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb,
|
|
|
|
nsISupports* aClosure)
|
2011-12-08 21:42:20 -08:00
|
|
|
{
|
|
|
|
nsGlobalWindow::WindowByIdTable* windowsById =
|
|
|
|
nsGlobalWindow::GetWindowsTable();
|
|
|
|
NS_ENSURE_TRUE(windowsById, NS_OK);
|
|
|
|
|
|
|
|
// Hold on to every window in memory so that window objects can't be
|
|
|
|
// destroyed while we're calling the memory reporter callback.
|
|
|
|
WindowArray windows;
|
|
|
|
windowsById->Enumerate(GetWindows, &windows);
|
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
// Get the IDs of all the "ghost" windows.
|
|
|
|
nsTHashtable<nsUint64HashKey> ghostWindows;
|
|
|
|
ghostWindows.Init();
|
|
|
|
CheckForGhostWindows(&ghostWindows);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEffectiveTLDService> tldService = do_GetService(
|
|
|
|
NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
NS_ENSURE_STATE(tldService);
|
|
|
|
|
2011-12-08 21:42:20 -08:00
|
|
|
// Collect window memory usage.
|
2012-02-21 07:10:11 -08:00
|
|
|
nsWindowSizes windowTotalSizes(NULL);
|
2012-04-02 19:28:04 -07:00
|
|
|
for (PRUint32 i = 0; i < windows.Length(); i++) {
|
|
|
|
nsresult rv = CollectWindowReports(windows[i], &windowTotalSizes,
|
|
|
|
&ghostWindows, aCb, aClosure);
|
2012-03-04 15:26:30 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2011-12-08 21:42:20 -08:00
|
|
|
}
|
2011-06-29 04:06:43 -07:00
|
|
|
|
2012-02-21 07:10:11 -08:00
|
|
|
#define REPORT(_path, _amount, _desc) \
|
|
|
|
do { \
|
2012-03-04 15:26:30 -08:00
|
|
|
nsresult rv; \
|
|
|
|
rv = aCb->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \
|
|
|
|
nsIMemoryReporter::KIND_OTHER, \
|
|
|
|
nsIMemoryReporter::UNITS_BYTES, _amount, \
|
|
|
|
NS_LITERAL_CSTRING(_desc), aClosure); \
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv); \
|
2012-02-21 07:10:11 -08:00
|
|
|
} while (0)
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/dom/other", windowTotalSizes.mDOMOther,
|
2012-06-05 07:49:48 -07:00
|
|
|
"Memory used for the DOM within windows, "
|
|
|
|
"excluding element, text, CDATA, and comment nodes. "
|
|
|
|
"This is the sum of all windows' 'dom/other' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/dom/element-nodes", windowTotalSizes.mDOMElementNodes,
|
2012-06-05 07:49:48 -07:00
|
|
|
"Memory used for DOM element nodes within windows. "
|
|
|
|
"This is the sum of all windows' 'dom/element-nodes' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/dom/text-nodes", windowTotalSizes.mDOMTextNodes,
|
2012-06-05 07:49:48 -07:00
|
|
|
"Memory used for DOM text nodes within windows. "
|
|
|
|
"This is the sum of all windows' 'dom/text-nodes' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/dom/cdata-nodes", windowTotalSizes.mDOMCDATANodes,
|
2012-06-05 07:49:48 -07:00
|
|
|
"Memory used for DOM CDATA nodes within windows. "
|
|
|
|
"This is the sum of all windows' 'dom/cdata-nodes' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/dom/comment-nodes", windowTotalSizes.mDOMCommentNodes,
|
2012-06-05 07:49:48 -07:00
|
|
|
"Memory used for DOM comment nodes within windows. "
|
|
|
|
"This is the sum of all windows' 'dom/comment-nodes' numbers.");
|
|
|
|
|
2012-06-14 21:10:08 -07:00
|
|
|
REPORT("window-objects/property-tables",
|
|
|
|
windowTotalSizes.mPropertyTables,
|
|
|
|
"Memory used for property tables within windows. "
|
|
|
|
"This is the sum of all windows' 'property-tables' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/style-sheets", windowTotalSizes.mStyleSheets,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used for style sheets within windows. "
|
|
|
|
"This is the sum of all windows' 'style-sheets' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/pres-shell", windowTotalSizes.mLayoutPresShell,
|
2012-05-11 06:23:07 -07:00
|
|
|
"Memory used by layout PresShell and other related "
|
2012-02-21 07:10:11 -08:00
|
|
|
"areas within windows. This is the sum of all windows' "
|
|
|
|
"'layout/arenas' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/line-boxes",
|
2012-06-06 10:35:40 -07:00
|
|
|
windowTotalSizes.mArenaStats.mLineBoxes,
|
|
|
|
"Memory used for line-boxes within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/line-boxes' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/rule-nodes",
|
2012-06-06 10:35:40 -07:00
|
|
|
windowTotalSizes.mArenaStats.mRuleNodes,
|
|
|
|
"Memory used for CSS rule nodes within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/rule-nodes' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/style-contexts",
|
2012-06-06 10:35:40 -07:00
|
|
|
windowTotalSizes.mArenaStats.mStyleContexts,
|
|
|
|
"Memory used for style contexts within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/style-contexts' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/style-sets", windowTotalSizes.mLayoutStyleSets,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used for style sets within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/style-sets' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/text-runs", windowTotalSizes.mLayoutTextRuns,
|
2012-02-21 07:10:11 -08:00
|
|
|
"Memory used for text runs within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/text-runs' numbers.");
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/pres-contexts", windowTotalSizes.mLayoutPresContext,
|
2012-05-11 06:23:07 -07:00
|
|
|
"Memory used for layout PresContexts within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/pres-contexts' numbers.");
|
|
|
|
|
2012-06-06 10:29:16 -07:00
|
|
|
size_t frameTotal = 0;
|
|
|
|
#define FRAME_ID(classname) \
|
|
|
|
frameTotal += windowTotalSizes.mArenaStats.FRAME_ID_STAT_FIELD(classname);
|
|
|
|
#include "nsFrameIdList.h"
|
|
|
|
#undef FRAME_ID
|
|
|
|
|
2012-06-11 20:32:26 -07:00
|
|
|
REPORT("window-objects/layout/frames", frameTotal,
|
2012-06-06 10:29:16 -07:00
|
|
|
"Memory used for layout frames within windows. "
|
|
|
|
"This is the sum of all windows' 'layout/frames/' numbers.");
|
|
|
|
|
2012-02-21 07:10:11 -08:00
|
|
|
#undef REPORT
|
|
|
|
|
2011-06-29 04:01:07 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-12 19:04:12 -08:00
|
|
|
NS_IMETHODIMP
|
2012-02-23 18:43:33 -08:00
|
|
|
nsWindowMemoryReporter::GetExplicitNonHeap(PRInt64* aAmount)
|
2011-12-12 19:04:12 -08:00
|
|
|
{
|
|
|
|
// This reporter only measures heap memory.
|
|
|
|
*aAmount = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-04-02 19:28:05 -07:00
|
|
|
PRUint32
|
|
|
|
nsWindowMemoryReporter::GetGhostTimeout()
|
|
|
|
{
|
|
|
|
return Preferences::GetUint("memory.ghost_window_timeout_seconds", 60);
|
|
|
|
}
|
|
|
|
|
2012-04-02 19:28:04 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::Observe(nsISupports *aSubject, const char *aTopic,
|
|
|
|
const PRUnichar *aData)
|
|
|
|
{
|
2012-04-02 19:28:05 -07:00
|
|
|
if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC)) {
|
|
|
|
ObserveDOMWindowDetached(aSubject);
|
|
|
|
} else if (!strcmp(aTopic, "after-minimize-memory-usage")) {
|
|
|
|
ObserveAfterMinimizeMemoryUsage();
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
}
|
2012-04-02 07:37:04 -07:00
|
|
|
|
2012-04-02 19:28:05 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-04-02 19:28:04 -07:00
|
|
|
|
|
|
|
void
|
2012-04-02 19:28:05 -07:00
|
|
|
nsWindowMemoryReporter::ObserveDOMWindowDetached(nsISupports* aWindow)
|
2012-04-02 19:28:04 -07:00
|
|
|
{
|
|
|
|
nsWeakPtr weakWindow = do_GetWeakReference(aWindow);
|
|
|
|
if (!weakWindow) {
|
|
|
|
NS_WARNING("Couldn't take weak reference to a window?");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mDetachedWindows.Put(weakWindow, TimeStamp());
|
|
|
|
|
|
|
|
if (!mCheckForGhostWindowsCallbackPending) {
|
|
|
|
nsCOMPtr<nsIRunnable> runnable =
|
|
|
|
NS_NewRunnableMethod(this,
|
|
|
|
&nsWindowMemoryReporter::CheckForGhostWindowsCallback);
|
|
|
|
NS_DispatchToCurrentThread(runnable);
|
|
|
|
mCheckForGhostWindowsCallbackPending = true;
|
|
|
|
}
|
2012-04-02 19:28:05 -07:00
|
|
|
}
|
2012-04-02 19:28:04 -07:00
|
|
|
|
2012-04-02 19:28:05 -07:00
|
|
|
static PLDHashOperator
|
|
|
|
BackdateTimeStampsEnumerator(nsISupports *aKey, TimeStamp &aTimeStamp,
|
|
|
|
void* aClosure)
|
|
|
|
{
|
|
|
|
TimeStamp *minTimeStamp = static_cast<TimeStamp*>(aClosure);
|
|
|
|
|
|
|
|
if (!aTimeStamp.IsNull() && aTimeStamp > *minTimeStamp) {
|
|
|
|
aTimeStamp = *minTimeStamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindowMemoryReporter::ObserveAfterMinimizeMemoryUsage()
|
|
|
|
{
|
|
|
|
// Someone claims they've done enough GC/CCs so that all eligible windows
|
|
|
|
// have been free'd. So we deem that any windows which satisfy ghost
|
|
|
|
// criteria (1) and (2) now satisfy criterion (3) as well.
|
|
|
|
//
|
|
|
|
// To effect this change, we'll backdate some of our timestamps.
|
|
|
|
|
|
|
|
TimeStamp minTimeStamp = TimeStamp::Now() -
|
|
|
|
TimeDuration::FromSeconds(GetGhostTimeout());
|
|
|
|
|
|
|
|
mDetachedWindows.Enumerate(BackdateTimeStampsEnumerator,
|
|
|
|
&minTimeStamp);
|
2012-04-02 19:28:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWindowMemoryReporter::CheckForGhostWindowsCallback()
|
|
|
|
{
|
|
|
|
mCheckForGhostWindowsCallbackPending = false;
|
|
|
|
CheckForGhostWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
struct CheckForGhostWindowsEnumeratorData
|
|
|
|
{
|
|
|
|
nsTHashtable<nsCStringHashKey> *nonDetachedDomains;
|
|
|
|
nsTHashtable<nsUint64HashKey> *ghostWindowIDs;
|
|
|
|
nsIEffectiveTLDService *tldService;
|
|
|
|
PRUint32 ghostTimeout;
|
|
|
|
TimeStamp now;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
CheckForGhostWindowsEnumerator(nsISupports *aKey, TimeStamp& aTimeStamp,
|
|
|
|
void* aClosure)
|
|
|
|
{
|
|
|
|
CheckForGhostWindowsEnumeratorData *data =
|
|
|
|
static_cast<CheckForGhostWindowsEnumeratorData*>(aClosure);
|
|
|
|
|
|
|
|
nsWeakPtr weakKey = do_QueryInterface(aKey);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(weakKey);
|
|
|
|
if (!window) {
|
|
|
|
// The window object has been destroyed. Stop tracking its weak ref in our
|
|
|
|
// hashtable.
|
|
|
|
return PL_DHASH_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Avoid calling GetTop() if we have no outer window. Nothing will break if
|
|
|
|
// we do, but it will spew debug output, which can cause our test logs to
|
|
|
|
// overflow.
|
|
|
|
nsCOMPtr<nsIDOMWindow> top;
|
|
|
|
if (window->GetOuterWindow()) {
|
|
|
|
window->GetTop(getter_AddRefs(top));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (top) {
|
|
|
|
// The window is no longer detached, so we no longer want to track it.
|
|
|
|
return PL_DHASH_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri = GetWindowURI(window);
|
|
|
|
|
|
|
|
nsCAutoString domain;
|
|
|
|
if (uri) {
|
|
|
|
// GetBaseDomain works fine if |uri| is null, but it outputs a warning
|
|
|
|
// which ends up overrunning the mochitest logs.
|
|
|
|
data->tldService->GetBaseDomain(uri, 0, domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->nonDetachedDomains->Contains(domain)) {
|
|
|
|
// This window shares a domain with a non-detached window, so reset its
|
|
|
|
// clock.
|
|
|
|
aTimeStamp = TimeStamp();
|
|
|
|
} else {
|
|
|
|
// This window does not share a domain with a non-detached window, so it
|
|
|
|
// meets ghost criterion (2).
|
|
|
|
if (aTimeStamp.IsNull()) {
|
|
|
|
// This may become a ghost window later; start its clock.
|
|
|
|
aTimeStamp = data->now;
|
|
|
|
} else if ((data->now - aTimeStamp).ToSeconds() > data->ghostTimeout) {
|
|
|
|
// This definitely is a ghost window, so add it to ghostWindowIDs, if
|
|
|
|
// that is not null.
|
|
|
|
if (data->ghostWindowIDs) {
|
|
|
|
nsCOMPtr<nsPIDOMWindow> pWindow = do_QueryInterface(window);
|
|
|
|
if (pWindow) {
|
|
|
|
data->ghostWindowIDs->PutEntry(pWindow->WindowID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GetNonDetachedWindowDomainsEnumeratorData
|
|
|
|
{
|
|
|
|
nsTHashtable<nsCStringHashKey> *nonDetachedDomains;
|
|
|
|
nsIEffectiveTLDService *tldService;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
GetNonDetachedWindowDomainsEnumerator(const PRUint64& aId, nsGlobalWindow* aWindow,
|
|
|
|
void* aClosure)
|
|
|
|
{
|
|
|
|
GetNonDetachedWindowDomainsEnumeratorData *data =
|
|
|
|
static_cast<GetNonDetachedWindowDomainsEnumeratorData*>(aClosure);
|
|
|
|
|
|
|
|
// Null outer window implies null top, but calling GetTop() when there's no
|
|
|
|
// outer window causes us to spew debug warnings.
|
|
|
|
if (!aWindow->GetOuterWindow() || !aWindow->GetTop()) {
|
|
|
|
// This window is detached, so we don't care about its domain.
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri = GetWindowURI(aWindow);
|
|
|
|
|
|
|
|
nsCAutoString domain;
|
|
|
|
if (uri) {
|
|
|
|
data->tldService->GetBaseDomain(uri, 0, domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
data->nonDetachedDomains->PutEntry(domain);
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iterate over mDetachedWindows and update it to reflect the current state of
|
|
|
|
* the world. In particular:
|
|
|
|
*
|
|
|
|
* - Remove weak refs to windows which no longer exist.
|
|
|
|
*
|
|
|
|
* - Remove references to windows which are no longer detached.
|
|
|
|
*
|
|
|
|
* - Reset the timestamp on detached windows which share a domain with a
|
|
|
|
* non-detached window (they no longer meet ghost criterion (2)).
|
|
|
|
*
|
|
|
|
* - If a window now meets ghost criterion (2) but didn't before, set its
|
|
|
|
* timestamp to now.
|
|
|
|
*
|
|
|
|
* Additionally, if aOutGhostIDs is not null, fill it with the window IDs of
|
|
|
|
* all ghost windows we found.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsWindowMemoryReporter::CheckForGhostWindows(
|
|
|
|
nsTHashtable<nsUint64HashKey> *aOutGhostIDs /* = NULL */)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIEffectiveTLDService> tldService = do_GetService(
|
|
|
|
NS_EFFECTIVETLDSERVICE_CONTRACTID);
|
|
|
|
if (!tldService) {
|
|
|
|
NS_WARNING("Couldn't get TLDService.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow::WindowByIdTable *windowsById =
|
|
|
|
nsGlobalWindow::GetWindowsTable();
|
|
|
|
if (!windowsById) {
|
|
|
|
NS_WARNING("GetWindowsTable returned null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTHashtable<nsCStringHashKey> nonDetachedWindowDomains;
|
|
|
|
nonDetachedWindowDomains.Init();
|
|
|
|
|
|
|
|
// Populate nonDetachedWindowDomains.
|
|
|
|
GetNonDetachedWindowDomainsEnumeratorData nonDetachedEnumData =
|
|
|
|
{ &nonDetachedWindowDomains, tldService };
|
|
|
|
windowsById->EnumerateRead(GetNonDetachedWindowDomainsEnumerator,
|
|
|
|
&nonDetachedEnumData);
|
|
|
|
|
|
|
|
// Update mDetachedWindows and write the ghost window IDs into aOutGhostIDs,
|
|
|
|
// if it's not null.
|
|
|
|
CheckForGhostWindowsEnumeratorData ghostEnumData =
|
|
|
|
{ &nonDetachedWindowDomains, aOutGhostIDs, tldService,
|
2012-04-02 19:28:05 -07:00
|
|
|
GetGhostTimeout(), TimeStamp::Now() };
|
2012-04-02 19:28:04 -07:00
|
|
|
mDetachedWindows.Enumerate(CheckForGhostWindowsEnumerator,
|
|
|
|
&ghostEnumData);
|
|
|
|
}
|
2012-04-02 19:28:05 -07:00
|
|
|
|
2012-04-02 19:28:13 -07:00
|
|
|
NS_IMPL_ISUPPORTS1(nsWindowMemoryReporter::GhostURLsReporter,
|
2012-04-02 19:28:05 -07:00
|
|
|
nsIMemoryMultiReporter)
|
|
|
|
|
|
|
|
nsWindowMemoryReporter::
|
2012-04-02 19:28:13 -07:00
|
|
|
GhostURLsReporter::GhostURLsReporter(
|
2012-04-02 19:28:05 -07:00
|
|
|
nsWindowMemoryReporter* aWindowReporter)
|
|
|
|
: mWindowReporter(aWindowReporter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
2012-04-02 19:28:13 -07:00
|
|
|
GhostURLsReporter::GetName(nsACString& aName)
|
2012-04-02 19:28:05 -07:00
|
|
|
{
|
|
|
|
aName.AssignLiteral("ghost-windows");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
2012-04-02 19:28:13 -07:00
|
|
|
GhostURLsReporter::GetExplicitNonHeap(PRInt64* aOut)
|
2012-04-02 19:28:05 -07:00
|
|
|
{
|
|
|
|
*aOut = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ReportGhostWindowsEnumeratorData
|
|
|
|
{
|
|
|
|
nsIMemoryMultiReporterCallback* callback;
|
|
|
|
nsISupports* closure;
|
|
|
|
nsresult rv;
|
|
|
|
};
|
|
|
|
|
|
|
|
static PLDHashOperator
|
|
|
|
ReportGhostWindowsEnumerator(nsUint64HashKey* aIDHashKey, void* aClosure)
|
|
|
|
{
|
|
|
|
ReportGhostWindowsEnumeratorData *data =
|
|
|
|
static_cast<ReportGhostWindowsEnumeratorData*>(aClosure);
|
|
|
|
|
|
|
|
nsGlobalWindow::WindowByIdTable* windowsById =
|
|
|
|
nsGlobalWindow::GetWindowsTable();
|
|
|
|
if (!windowsById) {
|
|
|
|
NS_WARNING("Couldn't get window-by-id hashtable?");
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsGlobalWindow* window = windowsById->Get(aIDHashKey->GetKey());
|
|
|
|
if (!window) {
|
|
|
|
NS_WARNING("Could not look up window?");
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCAutoString path;
|
|
|
|
path.AppendLiteral("ghost-windows/");
|
|
|
|
AppendWindowURI(window, path);
|
|
|
|
|
|
|
|
nsresult rv = data->callback->Callback(
|
|
|
|
/* process = */ EmptyCString(),
|
|
|
|
path,
|
2012-06-11 20:29:12 -07:00
|
|
|
nsIMemoryReporter::KIND_OTHER,
|
2012-04-02 19:28:05 -07:00
|
|
|
nsIMemoryReporter::UNITS_COUNT,
|
|
|
|
/* amount = */ 1,
|
|
|
|
/* desc = */ EmptyCString(),
|
|
|
|
data->closure);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv) && NS_SUCCEEDED(data->rv)) {
|
|
|
|
data->rv = rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PL_DHASH_NEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
2012-04-02 19:28:13 -07:00
|
|
|
GhostURLsReporter::CollectReports(
|
|
|
|
nsIMemoryMultiReporterCallback* aCb,
|
|
|
|
nsISupports* aClosure)
|
2012-04-02 19:28:05 -07:00
|
|
|
{
|
|
|
|
// Get the IDs of all the ghost windows in existance.
|
|
|
|
nsTHashtable<nsUint64HashKey> ghostWindows;
|
|
|
|
ghostWindows.Init();
|
|
|
|
mWindowReporter->CheckForGhostWindows(&ghostWindows);
|
|
|
|
|
|
|
|
ReportGhostWindowsEnumeratorData reportGhostWindowsEnumData =
|
|
|
|
{ aCb, aClosure, NS_OK };
|
|
|
|
|
|
|
|
// Call aCb->Callback() for each ghost window.
|
|
|
|
ghostWindows.EnumerateEntries(ReportGhostWindowsEnumerator,
|
|
|
|
&reportGhostWindowsEnumData);
|
|
|
|
|
|
|
|
return reportGhostWindowsEnumData.rv;
|
|
|
|
}
|
2012-04-02 19:28:13 -07:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsWindowMemoryReporter::NumGhostsReporter,
|
|
|
|
nsIMemoryReporter)
|
|
|
|
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::NumGhostsReporter(
|
|
|
|
nsWindowMemoryReporter *aWindowReporter)
|
|
|
|
: mWindowReporter(aWindowReporter)
|
|
|
|
{}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetProcess(nsACString& aProcess)
|
|
|
|
{
|
|
|
|
aProcess.AssignLiteral("");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetPath(nsACString& aPath)
|
|
|
|
{
|
|
|
|
aPath.AssignLiteral("ghost-windows");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetKind(PRInt32* aKind)
|
|
|
|
{
|
|
|
|
*aKind = KIND_OTHER;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetUnits(PRInt32* aUnits)
|
|
|
|
{
|
|
|
|
*aUnits = nsIMemoryReporter::UNITS_COUNT;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetDescription(nsACString& aDesc)
|
|
|
|
{
|
2012-04-24 11:43:00 -07:00
|
|
|
nsPrintfCString str(
|
2012-04-02 19:28:13 -07:00
|
|
|
"The number of ghost windows present (the number of nodes underneath \
|
|
|
|
explicit/window-objects/top(none)/ghost, modulo race conditions). A ghost \
|
|
|
|
window is not shown in any tab, does not share a domain with any non-detached \
|
|
|
|
windows, and has met these criteria for at least %ds \
|
|
|
|
(memory.ghost_window_timeout_seconds) or has survived a round of about:memory's \
|
|
|
|
minimize memory usage button.\n\n\
|
|
|
|
Ghost windows can happen legitimately, but they are often indicative of leaks \
|
|
|
|
in the browser or add-ons.",
|
|
|
|
mWindowReporter->GetGhostTimeout());
|
|
|
|
|
|
|
|
aDesc.Assign(str);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWindowMemoryReporter::
|
|
|
|
NumGhostsReporter::GetAmount(PRInt64* aAmount)
|
|
|
|
{
|
|
|
|
nsTHashtable<nsUint64HashKey> ghostWindows;
|
|
|
|
ghostWindows.Init();
|
|
|
|
mWindowReporter->CheckForGhostWindows(&ghostWindows);
|
|
|
|
|
|
|
|
*aAmount = ghostWindows.Count();
|
|
|
|
return NS_OK;
|
|
|
|
}
|