You are correct.
Execute the following on both Perl 5.8.8 and Perl 5.10.0 and I get different results.
Under Perl 5.8.8, I leak no memory and everything runs fine.
john@john-laptop:~/Projects/Cloud-T3n$ time perl refs.pl
1000000/1000000
real 0m53.021s
user 0m10.753s
sys 0m1.912s
Uses 200Mb of RAM.
john@john-laptop:~/Projects/Cloud-T3n$ time /usr/bin/perl refs.pl
1000000/1000000
real 0m58.048s
user 0m11.989s
sys 0m1.672s
Uses 2,476Kb RAM.
Please Note that I did as many folks right here have recommended and compiled my Perl 5.10.0 from the source on CPAN, without threads.
Perhaps we'll see some discussion on that here as well.
For reference, this is the exact code I am running:
package Top;
sub new {
my $class = shift;
my $s = bless { }, $class;
$s->{bottom} = Bottom->new( $s );
return $s;
}
#=====================================
package Bottom;
use Scalar::Util 'weaken';
sub new {
my ($class, $top) = @_;
my $s = bless { top => $top }, $class;
weaken($s->{top});
return $s;
}
#=====================================
package main;
use Devel::Cycle;
for( 1...1_000_000 )
{
print "\r$_/1000000";
my $top = Top->new();
my $bottom = $top->{bottom} or die "NO BOTTOM!";
$top = $bottom->{top} or die "NO TOP!";
find_cycle( $top );
find_cycle( $bottom );
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.