SlabCheck leaks memory into TopMemoryContext
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-hackers@postgresql.org
Date: 2020-01-16T04:41:19Z
Lists: pgsql-hackers
Hi Tomas, I just noticed that having a slab context around in an assertion build leads to performance degrading and memory usage going up. A bit of poking revealed that SlabCheck() doesn't free the freechunks it allocates. It's on its own obviously trivial to fix. But there's also this note at the top: * NOTE: report errors as WARNING, *not* ERROR or FATAL. Otherwise you'll * find yourself in an infinite loop when trouble occurs, because this * routine will be entered again when elog cleanup tries to release memory! which seems to be violated by doing: /* bitmap of free chunks on a block */ freechunks = palloc(slab->chunksPerBlock * sizeof(bool)); I guess it'd be better to fall back to malloc() here, and handle the allocation failure gracefully? Or perhaps we can just allocate something persistently during SlabCreate()? Greetings, Andres Freund
Commits
-
Allocate freechunks bitmap as part of SlabContext
- a801452c9e30 10.12 landed
- 8c37e4469d13 11.7 landed
- 162c951dfe8f 12.2 landed
- 543852fd8bf0 13.0 landed