Re: Possible memory leak with SQL function?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>
Cc: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Possible memory leak with SQL function?
Date: 2013-09-13 16:32:29
Message-ID: CA+TgmoZF3EFr8YKLF4hxAfbn9Qvy0uJriFr8HUC+=JyL84Ay7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 12, 2013 at 5:29 AM, Yeb Havinga <yebhavinga(at)gmail(dot)com> wrote:
> Is the following known behaviour, or should I put some time in writing a
> self contained test case?
>
> We have a function that takes a value and returns a ROW type. With the
> function implemented in language SQL, when executing this function in a
> large transaction, memory usage of the backend process increases.
> MemoryContextStats showed a lot of SQL function data. Debugging
> init_sql_fcache() showed that it was for the same function oid each time,
> and the oid was the function from value to ROW type.
>
> When the function is implemented in PL/pgSQL, the memory usage was much
> less.
>
> I'm sorry I cannot be more specific at the moment, such as what is 'much
> less' memory with a PL/pgSQl function, and are there as many SQL function
> data's as calls to the SQL function, because I would have to write a test
> case for this. I was just wondering, if this is known behavior of SQL
> functions vs PL/pgSQL functions, or could it be a bug?

It sounds like a bug to me, although I can't claim to know everything
there is to know about this topic.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-09-13 16:34:54 Re: proposal: Set effective_cache_size to greater of .conf value, shared_buffers
Previous Message Robert Haas 2013-09-13 16:31:08 Re: Successor of MD5 authentication, let's use SCRAM