Re: plpgsql function seems to be leaking memory

From: Marc Cousin <mcousin(at)sigma(dot)fr>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: plpgsql function seems to be leaking memory
Date: 2008-06-24 15:29:09
Message-ID: 200806241729.09998.mcousin@sigma.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tuesday 24 June 2008 16:56:10 Tom Lane wrote:
> Marc Cousin <mcousin(at)sigma(dot)fr> writes:
> > I'm having a problem with plpgsql functions leaking memory.
>
> Your example shows absolutely no memory leak here, in either 8.3.3
> or CVS HEAD.
>
> > I see the postgresql process growing from 8MB to about 400 MB during this
> > run...
>
> What do you have shared_buffers set to? I think you might be getting
> fooled by top's treatment of shared memory (ie, it starts to count
> shared pages after the process touches them for the first time).
>
> regards, tom lane

I'm seeing this with ps aux, you're (almost) right... And I've been wasting your time.

At the begining :
postgres 23305 39.2 0.8 1275484 31208 ? Rs 17:07 0:18 postgres: postgres test [local] idle in transaction

Then after a few seconds :
postgres 23305 39.2 0.8 1275484 31208 ? Rs 17:07 0:18 postgres: postgres test [local] idle in transaction

The RSS column is growing ... Here it is only a test, but I've been having
it get to more that 500MB on the real use case, and it got me worried...

shared_buffers is at 1GB...

So in fact, the problem is linked to RSS containing some shared memory...
And that this growing memory is because the process has put all those
modified blocks in the shared buffers... I've confirmed that with doing the
inserts out of plpgsql, and it's also the same if I select the process...
And I never noticed it before ...

It all started with a plperl procedure and I was afraid I had a leak in it ... :)

Sorry to have wasted your time and thanks a lot ...

Regards.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Guillaume Lelarge 2008-06-24 15:37:35 Re: plpgsql function seems to be leaking memory
Previous Message Tom Lane 2008-06-24 14:56:10 Re: plpgsql function seems to be leaking memory