Memory mess introduced by recent funcapi.c patch - Mailing list pgsql-hackers

From Tom Lane
Subject Memory mess introduced by recent funcapi.c patch
Date
Msg-id 27153.1227743054@sss.pgh.pa.us
Whole thread Raw
List pgsql-hackers
This patch:
http://archives.postgresql.org/pgsql-committers/2008-02/msg00356.php
which was alleged to prevent memory leaks, seems to have introduced
some.  The problem is that shutdown_MultiFuncCall() now performs aMemoryContextSwitchTo(flinfo->fn_mcxt);
which means that an exiting SRF will now leave CurrentMemoryContext
pointing at a long-lived context, not the short-lived context in which
the function was called.  Subsequent operations that think they are
running in a short-lived context (and hence can be cavalier about
whether to free allocations) now result in memory leaks.

Did you have a specific reason for adding that?  There was no trace
of any such switch before, and a quick check with the regression
tests shows no harm from taking it out.  Plus that makes the memory
leak I'm seeing go away ...

For the record, the test case that led me to this wasselect unnest((ts_debug(title)).lexemes) as lex from
publications_test;
where publications_test.title is a long column of article titles,
and I wanted to extract a single column of lexemes.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: What's going on with pgfoundry?
Next
From: "David Rowley"
Date:
Subject: Re: Windowing Function Patch Review -> Standard Conformance