src/backend/utils/mmgr/slab.c
static void
SlabStats(MemoryContext context,
		  MemoryStatsPrintFunc printfunc, void *passthru,
		  MemoryContextCounters *totals,
		  bool print_to_stderr)
{
	SlabContext *slab = castNode(SlabContext, context);
	Size		nblocks = 0;
	Size		freechunks = 0;
	Size		totalspace;
	Size		freespace = 0;
	int			i;

	/* Include context header in totalspace */
	totalspace = slab->headerSize;

	for (i = 0; i <= slab->chunksPerBlock; i++)
	{
		dlist_iter	iter;

		dlist_foreach(iter, &slab->freelist[i])
		{
			SlabBlock  *block = dlist_container(SlabBlock, node, iter.cur);

			nblocks++;
			totalspace += slab->blockSize;
			freespace += slab->fullChunkSize * block->nfree;
			freechunks += block->nfree;
		}
	}

	if (printfunc)
	{
		char		stats_string[200];

		snprintf(stats_string, sizeof(stats_string),
				 "%zu total in %zu blocks; %zu free (%zu chunks); %zu used",
				 totalspace, nblocks, freespace, freechunks,
				 totalspace - freespace);
		printfunc(context, passthru, stats_string, print_to_stderr);
	}

	if (totals)
	{
		totals->nblocks += nblocks;
		totals->freechunks += freechunks;
		totals->totalspace += totalspace;
		totals->freespace += freespace;
	}
}
/*
 * SlabStats
 *		Compute stats about memory consumption of a Slab context.
 *
 * printfunc: if not NULL, pass a human-readable stats string to this.
 * passthru: pass this pointer through to printfunc.
 * totals: if not NULL, add stats about this context into *totals.
 * print_to_stderr: print stats to stderr if true, elog otherwise.
 */
SlabStats
Compute stats about memory consumption of a Slab context.

if not NULL, pass a human-readable stats string to this.
passthru: pass this pointer through to printfunc.
totals: if not NULL, add stats about this context into *totals.
print_to_stderr: print stats to stderr if true, elog otherwise.
SlabStats Compute stats about memory consumption of a Slab context . if not NULL pass a human - readable stats string to this . passthru : pass this pointer through to printfunc . totals : if not NULL add stats about this context into * totals . print_to_stderr : print stats to stderr if true elog otherwise .
static void
SlabStats(MemoryContext context,
		  MemoryStatsPrintFunc printfunc, void *passthru,
		  MemoryContextCounters *totals,
		  bool print_to_stderr)
{
	SlabContext *slab = castNode(SlabContext, context);
	Size		nblocks = 0;
	Size		freechunks = 0;
	Size		totalspace;
	Size		freespace = 0;
	int			i;
	totalspace = slab->headerSize;
	for (i = 0; i <= slab->chunksPerBlock; i++)
	{
		dlist_iter	iter;
		dlist_foreach(iter, &slab->freelist[i])
		{
			SlabBlock  *block = dlist_container(SlabBlock, node, iter.cur);
			nblocks++;
			totalspace += slab->blockSize;
			freespace += slab->fullChunkSize * block->nfree;
			freechunks += block->nfree;
		}
	}
	if (printfunc)
	{
		char		stats_string[200];
		snprintf(stats_string, sizeof(stats_string),
				 "%zu total in %zu blocks; %zu free (%zu chunks); %zu used",
				 totalspace, nblocks, freespace, freechunks,
				 totalspace - freespace);
		printfunc(context, passthru, stats_string, print_to_stderr);
	}
	if (totals)
	{
		totals->nblocks += nblocks;
		totals->freechunks += freechunks;
		totals->totalspace += totalspace;
		totals->freespace += freespace;
	}
}
static void SlabStats ( MemoryContext context , MemoryStatsPrintFunc printfunc , void * passthru , MemoryContextCounters * totals , bool print_to_stderr ) { SlabContext * slab = castNode ( SlabContext , context ) ; Size nblocks = 0 ; Size freechunks = 0 ; Size totalspace ; Size freespace = 0 ; int i ; totalspace = slab -> headerSize ; for ( i = 0 ; i <= slab -> chunksPerBlock ; i ++ ) { dlist_iter iter ; dlist_foreach ( iter , & slab -> freelist [ i ] ) { SlabBlock * block = dlist_container ( SlabBlock , node , iter . cur ) ; nblocks ++ ; totalspace += slab -> blockSize ; freespace += slab -> fullChunkSize * block -> nfree ; freechunks += block -> nfree ; } } if ( printfunc ) { char stats_string [ 200 ] ; snprintf ( stats_string , sizeof ( stats_string ) , " " , totalspace , nblocks , freespace , freechunks , totalspace - freespace ) ; printfunc ( context , passthru , stats_string , print_to_stderr ) ; } if ( totals ) { totals -> nblocks += nblocks ; totals -> freechunks += freechunks ; totals -> totalspace += totalspace ; totals -> freespace += freespace ; } }
SlabStats
              Compute stats about memory consumption of a Slab context.
SlabStats Compute stats about memory consumption of a Slab context .
/* Include context header in totalspace */