pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allocate freechunks bitmap as part of SlabContext
Date: Fri, 17 Jan 2020 14:31:50 +0000
Message-ID: <E1isSf8-0002JM-3u@gemulon.postgresql.org> (raw)

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

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8c37e4469d13e34d80b6f561f617bd4bfe339c6c

Modified Files
--------------
src/backend/utils/mmgr/slab.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1isSf8-0002JM-3u@gemulon.postgresql.org>
Permalink:  ../E1isSf8-0002JM-3u@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1isSf8-0002JM-3u@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Allocate freechunks bitmap as part of SlabContext
  In-Reply-To: <E1isSf8-0002JM-3u@gemulon.postgresql.org>
  References: <E1isSf8-0002JM-3u@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox