aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/mmgr/aset.c6
-rw-r--r--src/backend/utils/mmgr/generation.c2
-rw-r--r--src/include/nodes/memnodes.h2
3 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index ea23ac2ccb9..f729d9b6dec 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -1154,7 +1154,9 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
return NULL;
}
- context->mem_allocated += blksize - oldblksize;
+ /* updated separately, not to underflow when (oldblksize > blksize) */
+ context->mem_allocated -= oldblksize;
+ context->mem_allocated += blksize;
block->freeptr = block->endptr = ((char *) block) + blksize;
@@ -1427,7 +1429,7 @@ AllocSetCheck(MemoryContext context)
const char *name = set->header.name;
AllocBlock prevblock;
AllocBlock block;
- int64 total_allocated = 0;
+ Size total_allocated = 0;
for (prevblock = NULL, block = set->blocks;
block != NULL;
diff --git a/src/backend/utils/mmgr/generation.c b/src/backend/utils/mmgr/generation.c
index 2d24ab68bc0..b60a19f5a5f 100644
--- a/src/backend/utils/mmgr/generation.c
+++ b/src/backend/utils/mmgr/generation.c
@@ -753,7 +753,7 @@ GenerationCheck(MemoryContext context)
GenerationContext *gen = (GenerationContext *) context;
const char *name = context->name;
dlist_iter iter;
- int64 total_allocated = 0;
+ Size total_allocated = 0;
/* walk all blocks in this context */
dlist_foreach(iter, &gen->blocks)
diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h
index df0ae3625cb..854bd5d2256 100644
--- a/src/include/nodes/memnodes.h
+++ b/src/include/nodes/memnodes.h
@@ -79,7 +79,7 @@ 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 */
- int64 mem_allocated; /* track memory allocated for this context */
+ 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 */