I have found and consistently reproduced a serious memory leak in DBD::DB2
0.76. The workaround is to go back to version 0.75.
I ran the following script:
------------------------------------------
use DBI;
$ENV{DB2INSTANCE} = 'xxxx';
my $db = DBI->connect('dbi:DB2:est8','xxxx','xxxx');
sub getps {
my @a = split(/ +/,`ps auxww | grep t.pl | grep -v grep`);
return ($a[4],$a[5],$a[1]);
}
my @procorg;
sub ps {
my @proc = getps();
my $d1 = sprintf("%3.2f",$proc[0]/$procorg[0]*100.0);
my $d2 = sprintf("%3.2f",$proc[1]/$procorg[1]*100.0);
return "SZ ".($proc[0])." ($d1%) RSS ".($proc[1])." ($d2%)";
}
my $c = 0;
while (1) {
$c++;
my $st = $db->prepare('select * from resource');
$st->execute();
while (my $ref = $st->fetchrow_hashref()) {
}
$st->finish();
if ($c==1) {
@procorg = getps();
print "0 ".ps()."\n";
} elsif ($c % 10 == 0) {
print "$c ".ps()."\n";
}
}
--------------------------------------------
This is the output with version 0.75:
#perl t.pl
0 SZ 5560 (100.00%) RSS 5984 (100.00%)
10 SZ 5568 (100.14%) RSS 5992 (100.13%)
20 SZ 5576 (100.29%) RSS 6000 (100.27%)
30 SZ 5580 (100.36%) RSS 6004 (100.33%)
40 SZ 5584 (100.43%) RSS 6008 (100.40%)
50 SZ 5596 (100.65%) RSS 6020 (100.60%)
60 SZ 5600 (100.72%) RSS 6024 (100.67%)
70 SZ 5616 (101.01%) RSS 6040 (100.94%)
80 SZ 5624 (101.15%) RSS 6048 (101.07%)
90 SZ 5636 (101.37%) RSS 6060 (101.27%)
This is with version 0.76:
#perl t.pl
0 SZ 5548 (100.00%) RSS 5976 (100.00%)
10 SZ 6472 (116.65%) RSS 6900 (115.46%)
20 SZ 7500 (135.18%) RSS 7928 (132.66%)
30 SZ 8524 (153.64%) RSS 8952 (149.80%)
40 SZ 9556 (172.24%) RSS 9984 (167.07%)
50 SZ 10588 (190.84%) RSS 11016 (184.34%)
60 SZ 11616 (209.37%) RSS 12044 (201.54%)
70 SZ 12648 (227.97%) RSS 13076 (218.81%)
I have tried it with DBI versions 1.30 and 1.29.
--
Rune Nilsen
rune at tinde.com