Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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: srf_memory_leak-2.patch
Description: text/x-patch (3.3 KB)

Responses

pgsql-patches by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group