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