SRF memory leaks

From: Neil Conway <neilc(at)samurai(dot)com>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: SRF memory leaks
Date: 2008-02-25 21:32:10
Message-ID: 1203975130.31481.15.camel@dell.linuxdev.us.dell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
srf_memory_leak-2.patch text/x-patch 3.3 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2008-02-25 23:09:12 Re: lc_time and localized dates
Previous Message Peter Eisentraut 2008-02-25 21:16:02 Shlib exports file refactoring