From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgreSQL(dot)org |
Subject: | Memory leaks in record_out and record_send |
Date: | 2012-11-13 05:18:21 |
Message-ID: | 8810.1352783901@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I looked into the problem complained of here:
http://archives.postgresql.org/pgsql-general/2012-11/msg00279.php
which turns out to have nothing to do with joins and everything to do
with the fact that record_out() leaks memory like mad. It leaks both
the strings returned by the per-column output functions and any column
values that have to be detoasted. You can easily reproduce this with
an example like
create table leak (f1 int, f2 text);
insert into leak select x, 'foo' from generate_series(1,1000000) x;
select leak from leak;
The attached patch against HEAD fixes this, as well as a similar
leakage in record_send(). The added code is lifted directly from
printtup() so it's not adding any new assumptions to the system.
I wonder though if we ought to think about running output functions in
a short-lived memory context instead of the executor's main context.
We've considered that before, I think, and it's always been the path
of least resistance to fix the output functions instead --- but there
will always be another leak I'm afraid.
OTOH I can't see trying to back-patch a solution like that. If we want
to fix this in the back branches (and note the complaint linked above is
against 8.3), I think we have to do it as attached.
Thoughts?
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
record-out-leak.patch | text/x-patch | 5.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Amit kapila | 2012-11-13 05:51:25 | Re: Proof of concept: standalone backend with full FE/BE protocol |
Previous Message | Amit kapila | 2012-11-13 04:23:04 | Re: [PATCH] Patch to compute Max LSN of Data Pages |