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

From Tom Lane
Subject Re: SlabCheck leaks memory into TopMemoryContext
Date
Msg-id 2646.1579195983@sss.pgh.pa.us
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
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On Thu, Jan 16, 2020 at 08:48:49AM -0800, Andres Freund wrote:
>> 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.

> It's largely a matter of personal preference - I agree there are cases
> when global variables are the best solution, but I kinda dislike them.
> It seems cleaner to just allocate it as part of the slab, not having to
> deal with different number of chunks per block between slabs.
> Plus we don't have all that many slabs (like 2), and it's only really
> used in debug builds anyway. So I'm not all that woried about this
> wasting a couple extra kB of memory.

A positive argument for doing it like this is that the overhead goes away
when the SlabContexts are all deallocated, while a global variable would
presumably stick around indefinitely.  But I concur that in current usage,
there's hardly any point in worrying about the relative benefits.  We
should just keep it simple, and this seems marginally simpler than the
other way.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: our checks for read-only queries are not great
Next
From: Tomas Vondra
Date:
Subject: Re: psql - add SHOW_ALL_RESULTS option