aboutsummaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2020-03-18 15:39:14 -0700
committerJeff Davis <jdavis@postgresql.org>2020-03-18 15:39:14 -0700
commite00912e11a9ec2d29274ed8a6465e81385906dc2 (patch)
tree3a8cfa1201e76fe7e6129a86243abef6ca386c64 /src/include/nodes
parent487e9861d0cf83e9100ad0d0369147db3ef4ea73 (diff)
downloadpostgresql-e00912e11a9ec2d29274ed8a6465e81385906dc2.tar.gz
postgresql-e00912e11a9ec2d29274ed8a6465e81385906dc2.zip
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
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/memnodes.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h
index c9f2bbcb367..b6296af7d5f 100644
--- a/src/include/nodes/memnodes.h
+++ b/src/include/nodes/memnodes.h
@@ -63,6 +63,7 @@ typedef struct MemoryContextMethods
void (*reset) (MemoryContext context);
void (*delete_context) (MemoryContext context);
Size (*get_chunk_space) (MemoryContext context, void *pointer);
+ Size (*mem_allocated) (MemoryContext context);
bool (*is_empty) (MemoryContext context);
void (*stats) (MemoryContext context,
MemoryStatsPrintFunc printfunc, void *passthru,
@@ -79,7 +80,6 @@ typedef struct MemoryContextData
/* these two fields are placed here to minimize alignment wastage: */
bool isReset; /* T = no space alloced since last reset */
bool allowInCritSection; /* allow palloc in critical section */
- Size mem_allocated; /* track memory allocated for this context */
const MemoryContextMethods *methods; /* virtual function table */
MemoryContext parent; /* NULL if no parent (toplevel context) */
MemoryContext firstchild; /* head of linked list of children */