static void AllocSetDelete(MemoryContext context);
static Size AllocSetGetChunkSpace(MemoryContext context, void *pointer);
static bool AllocSetIsEmpty(MemoryContext context);
-static void AllocSetStats(MemoryContext context);
+static void AllocSetStats(MemoryContext context, int level);
#ifdef MEMORY_CONTEXT_CHECKING
static void AllocSetCheck(MemoryContext context);
* Displays stats about memory consumption of an allocset.
*/
static void
-AllocSetStats(MemoryContext context)
+AllocSetStats(MemoryContext context, int level)
{
AllocSet set = (AllocSet) context;
long nblocks = 0;
AllocBlock block;
AllocChunk chunk;
int fidx;
+ int i;
for (block = set->blocks; block != NULL; block = block->next)
{
freespace += chunk->size + ALLOC_CHUNKHDRSZ;
}
}
+
+ for (i = 0; i < level; i++)
+ fprintf(stderr, " ");
+
fprintf(stderr,
"%s: %lu total in %ld blocks; %lu free (%ld chunks); %lu used\n",
set->header.name, totalspace, nblocks, freespace, nchunks,
/* This is a transient link to the active portal's memory context: */
MemoryContext PortalContext = NULL;
+static void MemoryContextStatsInternal(MemoryContext context, int level);
+
/*****************************************************************************
* EXPORTED ROUTINES *
*/
void
MemoryContextStats(MemoryContext context)
+{
+ MemoryContextStatsInternal(context, 0);
+}
+
+static void
+MemoryContextStatsInternal(MemoryContext context, int level)
{
MemoryContext child;
AssertArg(MemoryContextIsValid(context));
- (*context->methods->stats) (context);
+ (*context->methods->stats) (context, level);
for (child = context->firstchild; child != NULL; child = child->nextchild)
- MemoryContextStats(child);
+ MemoryContextStatsInternal(child, level + 1);
}
-
/*
* MemoryContextCheck
* Check all chunks in the named context.
void (*delete) (MemoryContext context);
Size (*get_chunk_space) (MemoryContext context, void *pointer);
bool (*is_empty) (MemoryContext context);
- void (*stats) (MemoryContext context);
+ void (*stats) (MemoryContext context, int level);
#ifdef MEMORY_CONTEXT_CHECKING
void (*check) (MemoryContext context);
#endif