Sven Willenberger <sven@dmv.com> writes:
> I have been experiencing an issue with plperl and PostgreSQL 8.0.1 in
> that after calling a plperl function memory does not get released.
AFAICT the result of spi_exec_query gets released fine, as soon as it's
no longer referenced within perl. Perhaps your perl code is written in
such a way that a reference to the hash result value remains live after
the function exit?
I tried this:
create or replace function nrows(text) returns int as $$
my ($tabname) = @_;
my $rv = spi_exec_query("select * from $tabname");
return $rv->{processed};
$$ LANGUAGE plperl;
and ran it repeatedly against a large table. The memory usage went
up as expected, but back down again as soon as the function exited.
If you think it's actually a plperl bug, please show a self-contained
example.
regards, tom lane