Re: SlabCheck leaks memory into TopMemoryContext - Mailing list pgsql-hackers

From Andres Freund
Subject Re: SlabCheck leaks memory into TopMemoryContext
Date
Msg-id 20200116164849.75rzho6zn4qppnf3@alap3.anarazel.de
Whole thread Raw
In response to Re: SlabCheck leaks memory into TopMemoryContext  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: SlabCheck leaks memory into TopMemoryContext  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
Hi,

On 2020-01-16 17:25:00 +0100, Tomas Vondra wrote:
> On Thu, Jan 16, 2020 at 10:27:01AM -0500, Tom Lane wrote:
> > Andres Freund <andres@anarazel.de> writes:
> > > ... I thought you were asking whether
> > > any additional memory could just be avoided...
> > 
> > Well, I was kind of wondering that, but if it's not practical then
> > preallocating the space instead will do.
> > 
> 
> I don't think it's practical to rework the checks in a way that would
> not require allocations. Maybe it's possible, but I think it's not worth
> the extra complexity.
> 
> The attached fix should do the trick - it pre-allocates the space when
> creating the context. There is a bit of complexity because we want to
> allocate the space as part of the context header, but nothin too bad. We
> might optimize it a bit by using a regular bitmap (instead of just an
> array of bools), but I haven't done that.

I don't get why it's advantageous to allocate this once for each slab,
rather than having it as a global once for all slabs. But anyway, still
clearly better than the current situation.

- Andres



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: SlabCheck leaks memory into TopMemoryContext
Next
From: Tomas Vondra
Date:
Subject: Re: SlabCheck leaks memory into TopMemoryContext