| From: | Marc Cousin <mcousin(at)sigma(dot)fr> |
|---|---|
| To: | pgsql-admin(at)postgresql(dot)org |
| Subject: | plpgsql function seems to be leaking memory |
| Date: | 2008-06-24 08:56:29 |
| Message-ID: | 200806241056.29589.mcousin@sigma.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
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)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | C K | 2008-06-24 10:43:38 | Functions |
| Previous Message | P Kapat | 2008-06-24 04:55:52 | Re: adding a user library path.. |