Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit deb21f0

Browse files
committed
Log memory context stats to stderr when reporting a 'Memory exhausted'
error, so as to provide a starting point for debugging.
1 parent e69b8d4 commit deb21f0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/utils/mmgr/aset.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.35 2000/12/05 23:40:36 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.36 2001/01/06 21:59:39 tgl Exp $
1515
*
1616
* NOTE:
1717
* This is a new (Feb. 05, 1999) implementation of the allocation set
@@ -324,7 +324,10 @@ AllocSetContextCreate(MemoryContext parent,
324324

325325
block = (AllocBlock) malloc(blksize);
326326
if (block == NULL)
327+
{
328+
MemoryContextStats(TopMemoryContext);
327329
elog(ERROR, "Memory exhausted in AllocSetContextCreate()");
330+
}
328331
block->aset = context;
329332
block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ;
330333
block->endptr = ((char *) block) + blksize;
@@ -482,7 +485,10 @@ AllocSetAlloc(MemoryContext context, Size size)
482485
blksize = chunk_size + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ;
483486
block = (AllocBlock) malloc(blksize);
484487
if (block == NULL)
488+
{
489+
MemoryContextStats(TopMemoryContext);
485490
elog(ERROR, "Memory exhausted in AllocSetAlloc()");
491+
}
486492
block->aset = set;
487493
block->freeptr = block->endptr = ((char *) block) + blksize;
488494

@@ -673,7 +679,10 @@ AllocSetAlloc(MemoryContext context, Size size)
673679
}
674680

675681
if (block == NULL)
682+
{
683+
MemoryContextStats(TopMemoryContext);
676684
elog(ERROR, "Memory exhausted in AllocSetAlloc()");
685+
}
677686

678687
block->aset = set;
679688
block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ;
@@ -843,7 +852,10 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
843852
blksize = chksize + ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ;
844853
block = (AllocBlock) realloc(block, blksize);
845854
if (block == NULL)
855+
{
856+
MemoryContextStats(TopMemoryContext);
846857
elog(ERROR, "Memory exhausted in AllocSetReAlloc()");
858+
}
847859
block->freeptr = block->endptr = ((char *) block) + blksize;
848860

849861
/* Update pointers since block has likely been moved */

0 commit comments

Comments
 (0)