SRF memory leaks - Mailing list pgsql-patches

From Neil Conway
Subject SRF memory leaks
Date
Msg-id 1203975130.31481.15.camel@dell.linuxdev.us.dell.com
Whole thread Raw
Responses Re: SRF memory leaks  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Attached is a patch that fixes the SRF memory leaks I recently reported
on -hackers[1]. The patch creates a distinct memory context for the
SRF's "multi_call_memory_ctx", and then deletes that context when the
SRF finishes. This ensures that any user allocations made in this
context are reclaimed. The patch also frees a TupleDesc that was leaked
in the per-query context when nodeFunctionscan was rescanned. Along the
way, it also fixes a leak in shutdown_MultiFuncCall() ("attinmeta" was
freed, but its palloc'd fields were not.)

It would be possible to allocate the TupleDesc in the multi-call memory
context, but it doesn't seem worth bothering about to me (since it would
require passing the context from the RSI down to the FuncCallContext). I
also didn't try to have multiple SRFs in the same subquery block use the
same context -- that seems like a lot of pain for little gain.

Comments welcome -- I think this fix should be applied to back branches.

-Neil

[1] http://markmail.org/message/45hekjinzl3e5i6q


Attachment

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Shlib exports file refactoring
Next
From: Euler Taveira de Oliveira
Date:
Subject: Re: lc_time and localized dates