Bug 807883: Add the PL_SizeOfArenaPoolExcludingPool function to measure all

memory used by a PLArenaPool, excluding the PLArenaPool structure. The
patch is contributed by Nicholas Nethercote <nnethercote@mozilla.com>.
r=wtc.
Modified Files:
	plarena.c plarenas.h plds.def


git-svn-id: svn://10.0.0.236/trunk@264710 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
wtc%google.com
2013-02-10 18:34:43 +00:00
parent 6d9ebe3b3d
commit 09b9d71f92
3 changed files with 33 additions and 0 deletions

View File

@@ -345,6 +345,22 @@ PR_IMPLEMENT(void) PL_ArenaFinish(void)
once = pristineCallOnce;
}
PR_IMPLEMENT(size_t) PL_SizeOfArenaPoolExcludingPool(
PLArenaPool *pool, PLMallocSizeFn mallocSizeOf)
{
/*
* The first PLArena is within |pool|, so don't measure it. Subsequent
* PLArenas are separate and must measured.
*/
size_t size = 0;
PLArena *arena = pool->first.next;
while (arena) {
size += mallocSizeOf(arena);
arena = arena->next;
}
return size;
}
#ifdef PL_ARENAMETER
PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
{

View File

@@ -60,6 +60,19 @@ PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
*/
PR_EXTERN(void) PL_ClearArenaPool(PLArenaPool *pool, PRInt32 pattern);
/*
** A function like malloc_size() or malloc_usable_size() that returns the
** size of a heap block.
*/
typedef size_t (*PLMallocSizeFn)(const void *ptr);
/*
** Return all memory used by a PLArenaPool, excluding the PLArenaPool
** structure.
*/
PR_EXTERN(size_t) PL_SizeOfArenaPoolExcludingPool(
PLArenaPool *pool, PLMallocSizeFn mallocSizeOf);
PR_END_EXTERN_C
#endif /* PLARENAS_H */

View File

@@ -54,3 +54,7 @@ PL_HashTableRawLookupConst;
;+ global:
PL_ClearArenaPool;
;+} NSPR_4.1;
;+NSPR_4.9.6 {
;+ global:
PL_SizeOfArenaPoolExcludingPool;
;+} NSPR_4.8.5;