Bug 664913: Add about:memory reporter for xptiWorkingSet. r=njn

This commit is contained in:
Kyle Huey 2011-06-17 09:22:15 -07:00
parent 5fedcf09b2
commit 58316a84d3
3 changed files with 37 additions and 1 deletions

View File

@ -41,9 +41,22 @@
#include "xptiprivate.h"
#include "nsString.h"
#include "nsIMemoryReporter.h"
using namespace mozilla;
static PRInt64 GetXPTArenaSize(void*)
{
return XPT_SizeOfArena(gXPTIStructArena);
}
NS_MEMORY_REPORTER_IMPLEMENT(xptiWorkingSet,
"explicit/xpti-working-set",
MR_HEAP,
"Memory used by the XPCOM typelib system.",
GetXPTArenaSize,
nsnull)
#define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 1)
#define XPTI_HASHTABLE_SIZE 2048
@ -57,6 +70,8 @@ xptiWorkingSet::xptiWorkingSet()
gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
"xptiWorkingSet structs");
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(xptiWorkingSet));
}
static PLDHashOperator
@ -82,6 +97,6 @@ xptiWorkingSet::~xptiWorkingSet()
#ifdef NS_FREE_PERMANENT_DATA
XPT_DestroyArena(gXPTIStructArena);
#endif
}
}
XPTArena* gXPTIStructArena;

View File

@ -82,6 +82,9 @@ XPT_NotifyDoneLoading(XPTArena *arena);
XPT_PUBLIC_API(void)
XPT_ArenaFree(XPTArena *arena, void* block);
XPT_PUBLIC_API(size_t)
XPT_SizeOfArena(XPTArena *arena);
/* --------------------------------------------------------- */
#define XPT_MALLOC(_arena, _bytes) \

View File

@ -336,3 +336,21 @@ XPT_AssertFailed(const char *s, const char *file, PRUint32 lineno)
abort();
}
#endif
XPT_PUBLIC_API(size_t)
XPT_SizeOfArena(XPTArena *arena)
{
size_t n = sizeof(XPTArena);
BLK_HDR* cur;
BLK_HDR* next;
cur = arena->first;
while (cur) {
next = cur->next;
n += cur->size;
cur = next;
}
return n;
}