diff options
Diffstat (limited to 'src/backend/utils/mmgr/slab.c')
-rw-r--r-- | src/backend/utils/mmgr/slab.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c index 63750fbc81f..c928476c479 100644 --- a/src/backend/utils/mmgr/slab.c +++ b/src/backend/utils/mmgr/slab.c @@ -67,7 +67,6 @@ typedef struct SlabContext Size fullChunkSize; /* chunk size including header and alignment */ Size blockSize; /* block size */ Size headerSize; /* allocated size of context header */ - Size memAllocated; /* track memory allocated for this context */ int chunksPerBlock; /* number of chunks per block */ int minFreeChunks; /* min number of free chunks in any block */ int nblocks; /* number of blocks allocated */ @@ -133,7 +132,6 @@ static void *SlabRealloc(MemoryContext context, void *pointer, Size size); static void SlabReset(MemoryContext context); static void SlabDelete(MemoryContext context); static Size SlabGetChunkSpace(MemoryContext context, void *pointer); -static Size SlabMemAllocated(MemoryContext context); static bool SlabIsEmpty(MemoryContext context); static void SlabStats(MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, @@ -152,7 +150,6 @@ static const MemoryContextMethods SlabMethods = { SlabReset, SlabDelete, SlabGetChunkSpace, - SlabMemAllocated, SlabIsEmpty, SlabStats #ifdef MEMORY_CONTEXT_CHECKING @@ -265,7 +262,6 @@ SlabContextCreate(MemoryContext parent, slab->fullChunkSize = fullChunkSize; slab->blockSize = blockSize; slab->headerSize = headerSize; - slab->memAllocated = 0; slab->chunksPerBlock = chunksPerBlock; slab->minFreeChunks = 0; slab->nblocks = 0; @@ -291,17 +287,6 @@ SlabContextCreate(MemoryContext parent, } /* - * All memory currently allocated for this context (including fragmentation - * and freed chunks). - */ -static Size -SlabMemAllocated(MemoryContext context) -{ - SlabContext *slab = (SlabContext *) context; - return slab->memAllocated; -} - -/* * SlabReset * Frees all memory which is allocated in the given set. * @@ -337,14 +322,14 @@ SlabReset(MemoryContext context) #endif free(block); slab->nblocks--; - slab->memAllocated -= slab->blockSize; + context->mem_allocated -= slab->blockSize; } } slab->minFreeChunks = 0; Assert(slab->nblocks == 0); - Assert(slab->memAllocated == 0); + Assert(context->mem_allocated == 0); } /* @@ -422,7 +407,7 @@ SlabAlloc(MemoryContext context, Size size) slab->minFreeChunks = slab->chunksPerBlock; slab->nblocks += 1; - slab->memAllocated += slab->blockSize; + context->mem_allocated += slab->blockSize; } /* grab the block from the freelist (even the new block is there) */ @@ -516,7 +501,7 @@ SlabAlloc(MemoryContext context, Size size) SlabAllocInfo(slab, chunk); - Assert(slab->nblocks * slab->blockSize == slab->memAllocated); + Assert(slab->nblocks * slab->blockSize == context->mem_allocated); return SlabChunkGetPointer(chunk); } @@ -593,13 +578,13 @@ SlabFree(MemoryContext context, void *pointer) { free(block); slab->nblocks--; - slab->memAllocated -= slab->blockSize; + context->mem_allocated -= slab->blockSize; } else dlist_push_head(&slab->freelist[block->nfree], &block->node); Assert(slab->nblocks >= 0); - Assert(slab->nblocks * slab->blockSize == slab->memAllocated); + Assert(slab->nblocks * slab->blockSize == context->mem_allocated); } /* @@ -819,7 +804,7 @@ SlabCheck(MemoryContext context) } } - Assert(slab->nblocks * slab->blockSize == slab->memAllocated); + Assert(slab->nblocks * slab->blockSize == context->mem_allocated); } #endif /* MEMORY_CONTEXT_CHECKING */ |