Re: Memory leak in vac_update_relstats ?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>, "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Memory leak in vac_update_relstats ?
Date: 2007-07-20 19:52:02
Message-ID: 87wswu7t0d.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Personally I've been thinking of mounting an effort to get rid of
> unnecessary pfree's wherever possible. Particularly in user-defined
> functions, "cleaning up" at the end is a waste of code space and
> cycles too, because they're typically called in contexts that are
> going to be reset immediately afterward.

It seems like the impact of this is self-limiting though. The worst-case is
going to be something which executes an extra pfree for every tuple. Or
perhaps one for every expression in a complex query involving lots of
expressions. Saving a few extra pfrees per tuple isn't really going to buy
many cpu cycles.

> In the case of vac_update_relstats, it's called only once per
> transaction, so there's certainly no point in being a neatnik.
> Stuff you need to worry about is functions that might be called
> many times in the same memory context.

Fwiw there are user-space functions that can't leak memory. I'm sure everyone
knows about btree operators, but pgsql also assumes that type input and output
functions don't leak memory too (or else assignment leaks memory in the
function scope memory context and in a loop...).

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-07-20 20:05:39 Re: 8.2.4 signal 11 with large transaction
Previous Message Bill Moran 2007-07-20 19:39:26 Re: Solved? Re: 8.2.4 signal 11 with large transaction