memory leak in auto_explain - Mailing list pgsql-hackers

From Jeff Janes
Subject memory leak in auto_explain
Date
Msg-id CAMkU=1wCVtbeRn0s9gt12KwQ7PLXovbpM8eg25SYocKW3BT4hg@mail.gmail.com
Whole thread Raw
Responses Re: memory leak in auto_explain
List pgsql-hackers
I accidentally tried to populate a test case while auto_explain.log_min_duration was set to zero.  auto_explain.log_nested_statements was also on.  

create or replace function gibberish(int) returns text language SQL as $_$ select left(string_agg(md5(random()::text),$$$$),$1) from generate_series(0,$1/32) $_$;

create table j1 as select x, md5(random()::text) as t11, gibberish(1500) as t12 from generate_series(1,20e6) f(x);

I got logorrhea of course, but I also got a memory leak into the SQL function context:

  TopPortalContext: 8192 total in 1 blocks; 7656 free (0 chunks); 536 used
    PortalContext: 16384 total in 5 blocks; 5328 free (1 chunks); 11056 used: <unnamed>
      ExecutorState: 4810120 total in 13 blocks; 4167160 free (74922 chunks); 642960 used
        SQL function: 411058232 total in 60 blocks; 4916568 free (4 chunks); 406141664 used: gibberish

The memory usage grew until OOM killer stepped in.

Cheers,

Jeff

pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: Proposal: Save user's original authenticated identity for logging
Next
From: Jeff Janes
Date:
Subject: Re: memory leak in auto_explain