8000 Report memory context stats upon out-of-memory in repalloc[_huge]. · prmdeveloper/postgres@a7915f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a7915f1

Browse files
committed
Report memory context stats upon out-of-memory in repalloc[_huge].
This longstanding functionality evidently got lost in commit 3d6d1b5. Noted while studying an OOM report from Jaime Casanova. Backpatch to 9.5 where the bug was introduced.
1 parent 1598dc1 commit a7915f1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/utils/mmgr/mcxt.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,13 @@ repalloc(void *pointer, Size size)
969969

970970
ret = (*context->methods->realloc) (context, pointer, size);
971971
if (ret == NULL)
972+
{
973+
MemoryContextStats(TopMemoryContext);
972974
ereport(ERROR,
973975
(errcode(ERRCODE_OUT_OF_MEMORY),
974976
errmsg("out of memory"),
975977
errdetail("Failed on request of size %zu.", size)));
978+
}
976979

977980
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
978981

@@ -1049,10 +1052,13 @@ repalloc_huge(void *pointer, Size size)
10491052

10501053
ret = (*context->methods->realloc) (context, pointer, size);
10511054
if (ret == NULL)
1055+
{
1056+
MemoryContextStats(TopMemoryContext);
10521057
ereport(ERROR,
10531058
(errcode(ERRCODE_OUT_OF_MEMORY),
10541059
errmsg("out of memory"),
10551060
errdetail("Failed on request of size %zu.", size)));
1061+
}
10561062

10571063
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
10581064

0 commit comments

Comments
 (0)
0