]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Allocate freechunks bitmap as part of SlabContext
authorTomas Vondra <tomas.vondra@postgresql.org>
Fri, 17 Jan 2020 13:06:28 +0000 (14:06 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Fri, 17 Jan 2020 14:30:51 +0000 (15:30 +0100)
commit162c951dfe8f0a894f2832e04aacfc3a0a7bf50c
tree1df5e44d1639a02a21ecc494fb6048f2824e5bf2
parent0fca3d0a4ec297bff5a5cb01dfe345e0f63d7d63
Allocate freechunks bitmap as part of SlabContext

The bitmap used by SlabCheck to cross-check free chunks in a block used
to be allocated for each SlabCheck call, and was never freed. The memory
leak could be fixed by simply adding a pfree call, but it's actually a
bad idea to do any allocations in SlabCheck at all as it assumes the
state of the memory management as a whole is sane.

So instead we allocate the bitmap as part of SlabContext, which means
we don't need to do any allocations in SlabCheck and the bitmap goes
away together with the SlabContext.

Backpatch to 10, where the Slab context was introduced.

Author: Tomas Vondra
Reported-by: Andres Freund
Reviewed-by: Tom Lane
Backpatch-through: 10
Discussion: https://www.postgresql.org/message-id/20200116044119.g45f7pmgz4jmodxj%40alap3.anarazel.de
src/backend/utils/mmgr/slab.c