Re: BUG #1739: memory leak in pl/perl with spi_exec_query

From: Jean-Max Reymond <jmreymond(at)ckr-solutions(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1739: memory leak in pl/perl with spi_exec_query
Date: 2005-06-30 13:48:05
Message-ID: 42C3F815.5020509@ckr-solutions.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jean-Max Reymond a écrit :

>The following bug has been logged online:
>
>Bug reference: 1739
>Logged by: Jean-Max Reymond
>Email address: jmreymond(at)ckr-solutions(dot)com
>PostgreSQL version: 8.0.3
>Operating system: Linux Ubuntu
>Description: memory leak in pl/perl with spi_exec_query
>Details:
>
>whith this code 1, postmaster is growing and growing and eat a lot of
>memory
>
>CREATE FUNCTION jmax() RETURNS integer
> AS $_$use strict;
>
>for (my $i=0; $i<10000000;$i++) {
> spi_exec_query("select 'foo'");
>}
>my $j=1;$_$
> LANGUAGE plperlu SECURITY DEFINER
>
>With code 2, we can see that perl does correctly the job to unreference
>unused memory
>
>CREATE FUNCTION jmax() RETURNS integer
> AS $_$use strict;
>
>for (my $i=0; $i<10000000;$i++) {
> my $ch = "0123456789"x100000;
>}
>my $j=1;$_$
> LANGUAGE plperlu SECURITY DEFINER
>
>With code 3, we try to help pl/perl to clean memory allocation
>
>CREATE FUNCTION jmax() RETURNS integer
> AS $_$use strict;
>
>for (my $i=0; $i<10000000;$i++) {
> my ch=spi_exec_query("select 'foo'");
>}
>my $j=1;$_$
> LANGUAGE plperlu SECURITY DEFINER
>
>
>So, spi_exec_query allocates memory but this memory is never released until
>the end of the stored procedure.
>For my application, the need is to call millions of spy_exec and we use 1.1
>Gb of not necessary memory.
>
>A workaround could be to provide a routine to free the memory allocated by
>spi_exec_query
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>
can anyone confirm this behavior ?
is it normal to have allocated memory in the pool even if this memory is
unreferenced ?
I am searching in the code but it is not very easy :-(

Attachment Content-Type Size
jmreymond.vcf text/x-vcard 321 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Cristian Cruz 2005-06-30 13:52:20 Re: BUG #1740: Deferred foreign key constraint isn't deferred
Previous Message Michael Fuhr 2005-06-30 13:44:34 Re: BUG #1740: Deferred foreign key constraint isn't deferred