mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user