Re: Probable memory leak with ECPG and AIX

From: Noah Misch <noah(at)leadboat(dot)com>
To: Benoit Lobréau <benoit(dot)lobreau(at)gmail(dot)com>
Cc: Guillaume Lelarge <guillaume(at)lelarge(dot)info>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>, "Dr(dot) Michael Meskes" <michael(dot)meskes(at)credativ(dot)com>
Subject: Re: Probable memory leak with ECPG and AIX
Date: 2022-01-01 07:40:55
Message-ID: 20220101074055.GA54621@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 15, 2021 at 04:20:42PM +0100, Benoit Lobréau wrote:
> * with LDR_CNTRL=MAXDATA=0x10000000, we reach 256Mo but there is no
> segfault, the program just continues running ;
> * with LDR_CNTRL=MAXDATA=0x80000000, we reach 2Go and there is no segfault
> either, the program just continues running.

I get the same results. The leak arises because AIX freelocale() doesn't free
all memory allocated in newlocale(). The following program uses trivial
memory on GNU/Linux, but it leaks like you're seeing on AIX:

#include <locale.h>
int main(int argc, char **argv)
{
while (1)
freelocale(newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0));
return 0;
}

If you have access to file an AIX bug, I recommend doing so. If we want
PostgreSQL to work around this, one idea is to have ECPG do this newlocale()
less often. For example, do it once per process or once per connection
instead of once per ecpg_do_prologue().

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2022-01-01 09:53:44 Re: Foreign key joins revisited
Previous Message Zhihong Yu 2022-01-01 02:43:07 Re: Speed up transaction completion faster after many relations are accessed in a transaction