]> granicus.if.org Git - postgresql/commitdiff
Report memory context stats upon out-of-memory in repalloc[_huge].
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Mar 2016 05:21:07 +0000 (00:21 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 13 Mar 2016 05:21:07 +0000 (00:21 -0500)
This longstanding functionality evidently got lost in commit
3d6d1b585524aab6.  Noted while studying an OOM report from Jaime
Casanova.  Backpatch to 9.5 where the bug was introduced.

src/backend/utils/mmgr/mcxt.c

index 2bfd364336b9457a35f40249945950fd169d8c90..6b7894213c10daa5968fd54f5605189172609749 100644 (file)
@@ -1051,10 +1051,13 @@ repalloc(void *pointer, Size size)
 
        ret = (*context->methods->realloc) (context, pointer, size);
        if (ret == NULL)
+       {
+               MemoryContextStats(TopMemoryContext);
                ereport(ERROR,
                                (errcode(ERRCODE_OUT_OF_MEMORY),
                                 errmsg("out of memory"),
                                 errdetail("Failed on request of size %zu.", size)));
+       }
 
        VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
 
@@ -1131,10 +1134,13 @@ repalloc_huge(void *pointer, Size size)
 
        ret = (*context->methods->realloc) (context, pointer, size);
        if (ret == NULL)
+       {
+               MemoryContextStats(TopMemoryContext);
                ereport(ERROR,
                                (errcode(ERRCODE_OUT_OF_MEMORY),
                                 errmsg("out of memory"),
                                 errdetail("Failed on request of size %zu.", size)));
+       }
 
        VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);