On Wed, Sep 24, 2003 at 03:51:50PM +0200, [EMAIL PROTECTED] wrote:
> Hi all,
>
> I'm working in a database migration project (Sybase ASE -> DB2 V8) with perl, DBI
> and DBD::DB2 and we have a memory leak problem when we run a lot of select
> statements during data import/export.
>
> We tested the System with different combinations of DBI (1.20 - 1.38), DBD::DB2
> (0.75-0.76) and DB2 V8.1.3 Fixpacks (FP2 + FP3).
>
> All test results in a more or less large memory leak (see Script output).
> Someone can help me or should we go back to Sybase ASE.
It's more likely to get fixed if you can narrow down the cause.
For example
does just doing prepare() in a loop leak, or
does just doing prepare() and execute() with no fetches leak, or
does fetchrow_arrayref leak (eg avoid hashes), or
etc etc
Tim.
> Rgds,
>
> Ruediger
>
>
> Script:
> ------
> #!/usr/bin/perl
>
> use strict;
> use locale;
> use DBI;
>
> my $dbh = DBI->connect('dbi:DB2:xxx','xxx','xxx',{AutoCommit => 1,});
>
> sub getps {
> my @a = split(/ +/,`ps auxww | grep _00_xx_test5.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) {
> my @RESULT = ();
> $c++;
> # select 13 records (ID, NAME, ID_TYPE)
> my $st = $dbh->prepare('select * from ut_attribute');
>
> $st->execute();
>
> # test 1
> # ------
> # while (my $ref = $st->fetchrow_hashref()) {
> # push (@RESULT, $ref);
> # }
>
> # test 2
> # ------
> # my $ref = $st->fetchall_hashref('ID');
>
> # test 3
> # ------
> while (my $hashref = $sth->fetchrow_hashref) {
> }
>
> $st->finish();
> if ($c==1) {
> @procorg = getps();
> print "0 ".ps()."\n";
> }
> elsif ($c % 1000 == 0) {
> print "$c ".ps()."\n";
> }
> }
> $dbh->disconnect;
>
>
> Script output:
> -------------
> with DBD::DB2 0.76
> ------------------
> 0 SZ 25412 (100.00%) RSS 11300 (100.00%)
> 1000 SZ 26196 (103.09%) RSS 12088 (106.97%)
> 2000 SZ 27028 (106.36%) RSS 12920 (114.34%)
> 3000 SZ 27860 (109.63%) RSS 13752 (121.70%)
> 4000 SZ 28692 (112.91%) RSS 14584 (129.06%)
> 5000 SZ 29524 (116.18%) RSS 15416 (136.42%)
> 6000 SZ 30356 (119.46%) RSS 16248 (143.79%)
> 7000 SZ 31188 (122.73%) RSS 17080 (151.15%)
> 8000 SZ 32020 (126.00%) RSS 17912 (158.51%)
> 9000 SZ 32852 (129.28%) RSS 18744 (165.88%)
> 10000 SZ 33684 (132.55%) RSS 19576 (173.24%)
> 11000 SZ 34512 (135.81%) RSS 20404 (180.57%)
>
>
> with DBD::DB2 0.75
> ------------------
> 0 SZ 25416 (100.00%) RSS 11296 (100.00%)
> 1000 SZ 25572 (100.61%) RSS 11456 (101.42%)
> 2000 SZ 25776 (101.42%) RSS 11660 (103.22%)
> 3000 SZ 25980 (102.22%) RSS 11864 (105.03%)
> 4000 SZ 26184 (103.02%) RSS 12068 (106.83%)
> 5000 SZ 26388 (103.82%) RSS 12272 (108.64%)
> 6000 SZ 26592 (104.63%) RSS 12476 (110.45%)
> 7000 SZ 26796 (105.43%) RSS 12680 (112.25%)
> 8000 SZ 27000 (106.23%) RSS 12884 (114.06%)
> 9000 SZ 27204 (107.03%) RSS 13088 (115.86%)
> 10000 SZ 27408 (107.84%) RSS 13292 (117.67%)
> 11000 SZ 27616 (108.66%) RSS 13500 (119.51%)
> 12000 SZ 27816 (109.44%) RSS 13700 (121.28%)
>
>
>
> Environment:
> ------------
> SuSE SLES 8
> Linux Kernel 2.4.19
> DB2/LINUX 8.1.3 (also testet Fixpack 2 (8.1.2))
> Perl 5.8.0
> DBI 1.38 (also tested 1.20 - 1.37)
> DBD::DB2 0.76 (also tested 0.75)
>
>