1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Specialize MemoryContextMemAllocated().

An AllocSet doubles the size of allocated blocks (up to maxBlockSize),
which means that the current block can represent half of the total
allocated space for the memory context. But the free space in the
current block may never have been touched, so don't count the
untouched memory as allocated for the purposes of
MemoryContextMemAllocated().

Discussion: https://postgr.es/m/ec63d70b668818255486a83ffadc3aec492c1f57.camel@j-davis.com
This commit is contained in:
Jeff Davis
2020-03-18 15:39:14 -07:00
parent 487e9861d0
commit e00912e11a
5 changed files with 77 additions and 28 deletions

View File

@@ -469,7 +469,7 @@ MemoryContextIsEmpty(MemoryContext context)
Size
MemoryContextMemAllocated(MemoryContext context, bool recurse)
{
Size total = context->mem_allocated;
Size total = context->methods->mem_allocated(context);
AssertArg(MemoryContextIsValid(context));
@@ -760,7 +760,6 @@ MemoryContextCreate(MemoryContext node,
node->methods = methods;
node->parent = parent;
node->firstchild = NULL;
node->mem_allocated = 0;
node->prevchild = NULL;
node->name = name;
node->ident = NULL;