Memory mess introduced by recent funcapi.c patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Memory mess introduced by recent funcapi.c patch
Date: 2008-11-26 23:44:14
Message-ID: 27153.1227743054@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 a
MemoryContextSwitchTo(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 was
select 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

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2008-11-26 23:50:02 Re: Windowing Function Patch Review -> Standard Conformance
Previous Message Marc G. Fournier 2008-11-26 23:03:26 Re: What's going on with pgfoundry?