Skip to content

Commit 4b98016

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 ab737f6 commit 4b98016

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
@@ -1051,10 +1051,13 @@ repalloc(void *pointer, Size size)
10511051

10521052
ret = (*context->methods->realloc) (context, pointer, size);
10531053
if (ret == NULL)
1054+
{
1055+
MemoryContextStats(TopMemoryContext);
10541056
ereport(ERROR,
10551057
(errcode(ERRCODE_OUT_OF_MEMORY),
10561058
errmsg("out of memory"),
10571059
errdetail("Failed on request of size %zu.", size)));
1060+
}
10581061

10591062
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
10601063

@@ -1131,10 +1134,13 @@ repalloc_huge(void *pointer, Size size)
11311134

11321135
ret = (*context->methods->realloc) (context, pointer, size);
11331136
if (ret == NULL)
1137+
{
1138+
MemoryContextStats(TopMemoryContext);
11341139
ereport(ERROR,
11351140
(errcode(ERRCODE_OUT_OF_MEMORY),
11361141
errmsg("out of memory"),
11371142
errdetail("Failed on request of size %zu.", size)));
1143+
}
11381144

11391145
VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
11401146

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy