Parallel::ForkManager && DBI memory leak ?

From: Ing. Branislav Gerzo (2ge_at_2ge.us)
Date: 12/30/04


Date: Thu, 30 Dec 2004 09:36:07 +0100
To: dbi-users@perl.org

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
 


Relevant Pages

  • Re: Parallel::ForkManager && DBI memory leak ?
    ... 1st.case -- The parent spawns the child and waits until the child is through before continuing. ... When I wrote script, I saw it is leaking memory, so I think it is DBI ...
    (perl.dbi.users)
  • Re: Apache, Oracle, Perl DBI Problems
    ... I believe at the start of every perl cgi script interfacing ... 'perl dbi oracle'. ...
    (perl.dbi.users)
  • Re: Why wont my script terminate?
    ... Laurie, here are a couple of other things to look at: ... You are not explicitly checking for errors on your DBI calls after the ... > Here's my script: ... > msgs in output file when testing) ...
    (perl.dbi.users)
  • InterBase MEMO/BLOB fields, data with size > 1MB
    ... my Perl script I have a code part that fetches a data from database ... Scriptwork just fine if the "content" in MEMO or BLOB ... DBD-InterBase with some other Perl module? ... "The DBI currently defines no way to insert or update LONG/LOB values ...
    (perl.dbi.users)
  • Re: Attribute Parameter Problem with bind_param( )
    ... I'm using the same DBI version on both, ... prompt. ... parameter problem in one of the methods called in the script. ... Here is the error from the error log: ...
    (comp.lang.perl.misc)