pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Benoit Lobréau <benoit.lobreau@gmail.com>
Cc: Guillaume Lelarge <guillaume@lelarge.info>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Cc: Dr. Michael Meskes <michael.meskes@credativ.com>
Subject: Re: Probable memory leak with ECPG and AIX
Date: Fri, 31 Dec 2021 23:40:55 -0800
Message-ID: <20220101074055.GA54621@rfd.leadboat.com> (raw)
In-Reply-To: <CAPE8EZ42eWAemjj58DO0WArCMDG2VYWut38aAGo9V8QH8ETqrg@mail.gmail.com>
References: <CAECtzeWMVW=b8=DJje_4F=OG9BeYLh-phLcCxZ-FBpii+O=SBQ@mail.gmail.com>
	<20211212073411.GA2218865@rfd.leadboat.com>
	<CAPE8EZ4ca2s5tDVHZzQ=iGh+rD8VX5r4Gk8zTTEeh9VaDOMnuQ@mail.gmail.com>
	<CAPE8EZ42eWAemjj58DO0WArCMDG2VYWut38aAGo9V8QH8ETqrg@mail.gmail.com>

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().





view thread (20+ messages)  latest in thread

Message-ID: <20220101074055.GA54621@rfd.leadboat.com>
Permalink:  ../20220101074055.GA54621@rfd.leadboat.com/
Also on:    postgresql.org/message-id/20220101074055.GA54621@rfd.leadboat.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: noah@leadboat.com, benoit.lobreau@gmail.com, guillaume@lelarge.info, michael.meskes@credativ.com
  Subject: Re: Probable memory leak with ECPG and AIX
  In-Reply-To: <20220101074055.GA54621@rfd.leadboat.com>

* 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