pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marc Cousin <mcousin@sigma.fr>
To: pgsql-admin@postgresql.org
Subject: plpgsql function seems to be leaking memory
Date: Tue, 24 Jun 2008 10:56:29 +0200
Message-ID: <200806241056.29589.mcousin@sigma.fr> (raw)

Hi,

I'm having a problem with plpgsql functions leaking memory.

I've reproduced the problem with this simple function here :

CREATE OR REPLACE FUNCTION ftest()
  RETURNS boolean AS
$BODY$BEGIN
INSERT INTO test2 values (1);
RETURN true;
END;$BODY$
  LANGUAGE 'plpgsql' VOLATILE;


test2 table is a one column table

CREATE TABLE test2
(
  id integer
)
WITH (OIDS=FALSE);



Then to see the leak, I've called it repeatedly with a perl program :

#!/usr/bin/perl -w
#
#
use DBI;
$dbh = DBI->connect("dbi:Pg:dbname=test","postgres");

my $statement = 'SELECT ftest ()';
$sth = $dbh->prepare($statement);
$dbh->begin_work();
for ($i=0;$i<1000000;$i++)
{
        $sth->execute();
}
$dbh->rollback();


I see the postgresql process growing from 8MB to about 400 MB during this 
run...

It only seems to happen when a function contains an insert statement (I don't 
see leaks when only selecting).



logs=# SELECT version();
                                      version
------------------------------------------------------------------------------------
 PostgreSQL 8.3.3 on x86_64-pc-linux-gnu, compiled by GCC cc (Debian 4.3.1-1) 
4.3.1
(1 row)






view thread (6+ messages)  latest in thread

Message-ID: <200806241056.29589.mcousin@sigma.fr>
Permalink:  ../200806241056.29589.mcousin@sigma.fr/
Also on:    postgresql.org/message-id/200806241056.29589.mcousin@sigma.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: mcousin@sigma.fr
  Subject: Re: plpgsql function seems to be leaking memory
  In-Reply-To: <200806241056.29589.mcousin@sigma.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox