Memory leak on local($dbh->{RaiseError})=1 is a perl bug

[email protected] (Tim Bunce)
Newsgroups perl.dbi.announce
Organization Paul Ingram Group, Software Systems, +44 1 483 862800
Message-ID <[email protected]>
Here's a copy of a bug report I just sent to perl5-porters.

FTI, DBI 1.15 will be released shortly :)

Tim.

----- Forwarded message from Tim Bunce <[email protected]> -----

Date: Fri, 30 Mar 2001 15:38:27 +0100
From: Tim Bunce <[email protected]>
To: Perl 5 porters <[email protected]>
Cc: Tim Bunce <[email protected]>
Subject: Memory leak localizing a tied variable

The script appended below demonstrates a memory leak when doing a
local() on a tied variable.

I found this because someone reported that local($dbh->{RaiseError})=1
(and similar) leaked memory and thought it maybe a DBI bug.
The script demonstrates that it's not.

Perl 5.005 and 5.006 leak but 5.004 doesn't. I've not got a 5.7.0
handy. I'd be grateful if someone could test it on the current bleadperl.

Thanks.

Tim.

#!/usr/local/bin/perl -w

print "localizing tied variable leak test for perl $]...\n";
# 5.006   does leak
# 5.00503 does leak
# 5.00404 doesn't leak

use strict;
use Tie::Hash;
tie my %tie_hash => 'Tie::StdHash';

my $count = 0;
my $ps = (-d '/proc') ? "ps -lp " : "ps -l";

mem_test() while 1;

sub mem_test {
    system("echo $count; $ps$$") if (($count++ % 1000) == 0);
    local($tie_hash{Foo}) = 1;
}

----- End forwarded message -----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.