From deb21f0f80d39204604a98ec8dfd285cb564b1bf Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 6 Jan 2001 21:59:39 +0000 Subject: [PATCH] Log memory context stats to stderr when reporting a 'Memory exhausted' error, so as to provide a starting point for debugging. --- src/backend/utils/mmgr/aset.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 6dca205528..cdb2601e38 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.35 2000/12/05 23:40:36 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.36 2001/01/06 21:59:39 tgl Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -324,7 +324,10 @@ AllocSetContextCreate(MemoryContext parent, block = (AllocBlock) malloc(blksize); if (block == NULL) + { + MemoryContextStats(TopMemoryContext); elog(ERROR, "Memory exhausted in AllocSetContextCreate()"); + } block->aset = context; block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ; block->endptr = ((char *) block) + blksize; @@ -482,7 +485,10 @@ AllocSetAlloc(MemoryContext context, Size size) blksize = chunk_size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ; block = (AllocBlock) malloc(blksize); if (block == NULL) + { + MemoryContextStats(TopMemoryContext); elog(ERROR, "Memory exhausted in AllocSetAlloc()"); + } block->aset = set; block->freeptr = block->endptr = ((char *) block) + blksize; @@ -673,7 +679,10 @@ AllocSetAlloc(MemoryContext context, Size size) } if (block == NULL) + { + MemoryContextStats(TopMemoryContext); elog(ERROR, "Memory exhausted in AllocSetAlloc()"); + } block->aset = set; block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ; @@ -843,7 +852,10 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size) blksize = chksize + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ; block = (AllocBlock) realloc(block, blksize); if (block == NULL) + { + MemoryContextStats(TopMemoryContext); elog(ERROR, "Memory exhausted in AllocSetReAlloc()"); + } block->freeptr = block->endptr = ((char *) block) + blksize; /* Update pointers since block has likely been moved */ -- 2.40.0