The following bug has been logged on the website:
Bug reference: 9223
Logged by: Sergey Burladyan
Email address: eshkinkot@gmail.com
PostgreSQL version: 9.2.6
Operating system: Debian testing
Description:
PostgreSQL 9.2.6 on x86_64-unknown-linux-gnu, compiled by gcc (Debian
4.8.2-10) 4.8.2, 64-bit
This is perl 5, version 18, subversion 2 (v5.18.2) built for
x86_64-linux-gnu-thread-multi
create function perl_test(IN data text, OUT v1 text, OUT v2 integer, OUT v3
integer, OUT v4 json, OUT v5 json)
returns record as
$BODY$
use strict;
use warnings;
my $res->{'v1'} = 'content';
return $res;
$BODY$
language plperlu volatile strict;
test case:
select count(perl_test('')) from generate_series(1, 1000000);
before:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14771 0.0 0.0 1127204 6916 ? Ss 20:16 0:00 postgres:
sergey sergey 127.0.0.1(60492) idle
after first run:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14771 20.5 1.0 1216824 88308 ? Ss 20:16 0:08 postgres:
sergey sergey 127.0.0.1(60492) idle
after second run:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14771 9.1 2.8 1360876 229488 ? Ss 20:16 0:16 postgres:
sergey sergey 127.0.0.1(60492) idle
similar plpgsql function does not create a memory leak:
create function plpgsql_test(IN data text, OUT v1 text, OUT v2 integer, OUT
v3 integer, OUT v4 json, OUT v5 json)
returns record as
$BODY$
begin
v1 := 'content';
end
$BODY$
language plpgsql volatile strict;
select count(plpgsql_test('')) from generate_series(1, 1000000);
first run, before:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14836 0.0 0.0 1126448 4064 ? Ss 20:21 0:00 postgres:
sergey sergey 127.0.0.1(60577) idle
after first run:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14836 5.4 0.0 1128924 5636 ? Ss 20:21 0:05 postgres:
sergey sergey 127.0.0.1(60577) idle
after second run:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14836 7.8 0.1 1131292 8108 ? Ss 20:21 0:10 postgres:
sergey sergey 127.0.0.1(60577) idle
after third run:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
sergey 14836 9.1 0.1 1131292 8108 ? Ss 20:21 0:15 postgres:
sergey sergey 127.0.0.1(60577) idle