FAQ
We are currently using: perl, v5.8.0 built for MSWin32-x86-multi-thread
The test code as following:
my $process = 1;
while ($process){
my $dbh = DBI->connect('dbi:Oracle:sid', $user, $pass, { AutoCommit => 0
});
if ($dbh =~ /ERR/)
{
exit;
}
$dbh->disconnect;
undef $dbh;
sleep(10);
}
The memory usage starts at 9mb and keeps up. Anybody notices this before?
and has a solution?
Thanks

Search Discussions

  • Michael A Chase at Dec 18, 2002 at 5:53 pm

    On Wed, 18 Dec 2002 11:08:14 -0600 "Zhou, Bixia" wrote:

    We are currently using: perl, v5.8.0 built for MSWin32-x86-multi-thread
    The test code as following:
    my $process = 1;
    while ($process){
    my $dbh = DBI->connect('dbi:Oracle:sid', $user, $pass, { AutoCommit =>

    });
    if ($dbh =~ /ERR/)
    {
    exit;
    }
    $dbh->disconnect;
    undef $dbh;
    sleep(10);
    }
    The memory usage starts at 9mb and keeps up. Anybody notices this before?
    and has a solution?
    I don't see how this will ever exit since $dbh is a blessed database
    handle, not a string.

    Try declaring $dbh before you start the loop instead of creating a fresh
    copy every time through the loop.

    my $process = 1;
    my $dbh;
    while ( $process ) {
    $dbh = DBI -> connect( "dbi:Oracle:$inst", $user, $pass,
    { AutoCommit => 0 } )
    or die "Connect to $inst as $user failed: $DBI::errstr";
    $dbh -> disconnect;
    undef $dbh;
    sleep(10);
    }

    --
    Mac :})
    ** I normally forward private questions to the appropriate mail list. **
    Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
    Give a hobbit a fish and he eats fish for a day.
    Give a hobbit a ring and he eats fish for an age.
  • Michael A Chase at Dec 18, 2002 at 6:26 pm

    On Wed, 18 Dec 2002 12:16:11 -0600 "Zhou, Bixia" wrote:

    I moved declare $dbh out of loop as you suggested, but memory usage didn't
    stop to grow.
    There may be a leak somewhere, but someone else will have to find it. When
    I had a perpetual script like this, I had it exit after 24 hours and had a
    new copy started every day by the system. That should at least bound the
    memory loss.
    -----Original Message-----
    From: Michael A Chase
    Sent: Wednesday, December 18, 2002 11:56 AM
    To: '[email protected]'; Zhou, Bixia
    Subject: Re: dbi help

    On Wed, 18 Dec 2002 11:08:14 -0600 "Zhou, Bixia" wrote:

    We are currently using: perl, v5.8.0 built for MSWin32-x86-multi-thread
    The test code as following:
    my $process = 1;
    while ($process){
    my $dbh = DBI->connect('dbi:Oracle:sid', $user, $pass, { AutoCommit =>
    });
    if ($dbh =~ /ERR/)
    {
    exit;
    }
    $dbh->disconnect;
    undef $dbh;
    sleep(10);
    }
    The memory usage starts at 9mb and keeps up. Anybody notices this before?
    and has a solution?
    --
    Mac :})
    ** I normally forward private questions to the appropriate mail list. **
    Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
    Give a hobbit a fish and he eats fish for a day.
    Give a hobbit a ring and he eats fish for an age.
  • Dave K at Dec 18, 2002 at 6:56 pm
    Environment WinNt, Perl v5.6.1
    code
    while (1) {
    $dbh = DBI->connect($orcs, $uname, $passw,
    {
    RaiseError => 0,
    PrintError => 0,
    AutoCommit => 0
    }) or dberr("C");
    $conn_count++;
    sleep 2;
    $dbh->disconnect;
    undef $dbh;
    sleep 8;
    last if $conn_count > 10; # 100 sec total
    }

    No mem leak, moderate usage. What are you using this script for? (just
    curious, private email ok)
    HTH
    David
    "Bixia Zhou" <[email protected]> wrote in message
    news:[email protected]...
    We are currently using: perl, v5.8.0 built for MSWin32-x86-multi-thread
    The test code as following:
    my $process = 1;
    while ($process){
    my $dbh = DBI->connect('dbi:Oracle:sid', $user, $pass, { AutoCommit => 0
    });
    if ($dbh =~ /ERR/)
    {
    exit;
    }
    $dbh->disconnect;
    undef $dbh;
    sleep(10);
    }
    The memory usage starts at 9mb and keeps up. Anybody notices this before?
    and has a solution?
    Thanks
  • Jacqui Caren at Dec 19, 2002 at 11:47 am

    On Wed, 18 Dec 2002 10:28:56 -0800 (PST), Michael A Chase wrote:
    On Wed, 18 Dec 2002 12:16:11 -0600 "Zhou, Bixia" wrote:

    I moved declare $dbh out of loop as you suggested, but memory usage didn't
    stop to grow.
    There may be a leak somewhere, but someone else will have to find it. When
    I had a perpetual script like this, I had it exit after 24 hours and had a
    new copy started every day by the system. That should at least bound the
    memory loss.
    Look ta the modules you are using - do anyof them use dubly linked lists or
    similar perl structures when perls garbage collect fails due to ref counts
    never getting to zero?

    Often the problem is due to use of HTML or XML parsers where the software does not
    'clear' down the parse tree when finished.

    Of could this is not a DBI issue but a general perl 'gotcha'.

    Jacqui

    Jacqui Caren, Ingram Group Ltd. [email protected]
    ph: +44 (0) 1483 8628xx main=00 fax=01 ddi=65
    http://www.ig.co.uk/ http://www.sitedirector.org/
    http://www.perl.co.uk/
  • Bill Bennett at Dec 19, 2002 at 12:20 pm

    on 2002-12-18 11:56:08-06, Michael A Chase wrote:
    On Wed, 18 Dec 2002 11:08:14 -0600 "Zhou, Bixia" wrote:

    We are currently using: perl, v5.8.0 built for MSWin32-x86-multi-thread
    The test code as following:
    my $process = 1;
    while ($process){
    my $dbh = DBI->connect('dbi:Oracle:sid', $user, $pass, { AutoCommit =>

    });
    if ($dbh =~ /ERR/)
    {
    exit;
    }
    $dbh->disconnect;
    undef $dbh;
    sleep(10);
    }
    The memory usage starts at 9mb and keeps up. Anybody notices this before?
    and has a solution?
    I don't see how this will ever exit since $dbh is a blessed database
    handle, not a string.

    Try declaring $dbh before you start the loop instead of creating a fresh
    copy every time through the loop.

    my $process = 1;
    my $dbh;
    while ( $process ) {
    $dbh = DBI -> connect( "dbi:Oracle:$inst", $user, $pass,
    { AutoCommit => 0 } )
    or die "Connect to $inst as $user failed: $DBI::errstr";
    $dbh -> disconnect;
    undef $dbh;
    sleep(10);
    }
    Perl 5.8 is known to have memory leaks related to the "stdio" layer.
    In UNIX, a workaround is to set the environment variable PERLIO
    to have the value "perlio" before invoking perl. This may or
    may not be related to your problem. In UNIX (using bash) the
    solution is to have an "export PERLIO=perlio" command before
    invoking perl.

    HTH,
    Bill B.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbi-users @
categoriesperl
postedDec 18, '02 at 5:08p
activeDec 19, '02 at 12:20p
posts6
users5
websitedbi.perl.org

People

Translate

site design / logo © 2023 Grokbase