Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2ABF3650EA1 for ; Tue, 24 Jun 2008 06:22:56 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34115-02 for ; Tue, 24 Jun 2008 06:22:45 -0300 (ADT) X-Greylist: delayed 00:26:11.705162 by SQLgrey-1.7.6 Received: from gslimes3.sigma.fr (mx.sigma.fr [194.50.39.191]) by postgresql.org (Postfix) with ESMTP id A4697650E8E for ; Tue, 24 Jun 2008 06:22:48 -0300 (ADT) Received: from gsw3mes2.groupesigma.fr (unknown [192.168.1.70]) by gslimes3.sigma.fr (Postfix) with ESMTP id E2B63346E6 for ; Tue, 24 Jun 2008 10:56:30 +0200 (CEST) Received: from marc.sigma.fr ([89.195.0.5]) by gsw3mes2.groupesigma.fr with Microsoft SMTPSVC(6.0.3790.3959); Tue, 24 Jun 2008 10:56:29 +0200 From: Marc Cousin Organization: Sigma Informatique To: pgsql-admin@postgresql.org Subject: plpgsql function seems to be leaking memory Date: Tue, 24 Jun 2008 10:56:29 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200806241056.29589.mcousin@sigma.fr> X-OriginalArrivalTime: 24 Jun 2008 08:56:29.0895 (UTC) FILETIME=[316D2D70:01C8D5D8] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200806/203 X-Sequence-Number: 29541 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)