Hi pals,

this is my first post to this mailing list. I have one problem, it is
maybe for you small, but for me a big problem. If I want improve my
scripts I _have_ to use parallel DB access. When I looked around I
come to Parallel::ForkManager module, easy to use.

When I wrote script, I saw it is leaking memory, so I think it is DBI
related problem, you will help me for sure, I hope, here is isolated
problem:

# this is just example script
use strict;
use warnings;
use Parallel::ForkManager;
use DBI;

my @links = (1 .. 1000);
my $pm = new Parallel::ForkManager(5);

foreach my $x (0..$#links) {
    $pm->start and next;
    my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost;port=3306", 
"root", "")
        or die "Can't connect: ", $DBI::errstr; 
    $dbh->{RaiseError} = 1;
    print "$links[$x]\n";
    # do something (read, update, insert from db)
    $dbh->do("INSERT INTO TEST (field) VALUES ($x)");
    $dbh->disconnect;
    $pm->finish;
}

on 100th iteration it uses around 20 MB of memory, on the 200th
iteration it is 30 MB!

I tried to destruct $dbh in many ways (undef for example), but nothing
helps. Could someone give me answer for this ?

And if this is not possible via ForkManager exist some simple script
with forking DBI?


--

 --. ,--  ,-     ICQ: 7552083      \|||/    `//EB: www.2ge.us
,--' |  - |--    IRC: [2ge]        (. .)    ,\\SN: 2ge!2ge_us
`====+==+=+===~  ~=============-o00-(_)-00o-================~
Growing old makes one miss a lot of things, but poor memory helps!OJW
 

Reply via email to