Re: Probable memory leak with ECPG and AIX - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Probable memory leak with ECPG and AIX
Date
Msg-id 20220101074055.GA54621@rfd.leadboat.com
Whole thread Raw
In response to Re: Probable memory leak with ECPG and AIX  (Benoit Lobréau <benoit.lobreau@gmail.com>)
Responses Re: Probable memory leak with ECPG and AIX
List 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().



pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: Speed up transaction completion faster after many relations are accessed in a transaction
Next
From: "Joel Jacobson"
Date:
Subject: Re: Foreign key joins revisited