jura05 has asked for the wisdom of the Perl Monks concerning the following question:
I found that garbage collection after weakening is extemely slow in some cases. Here is the code:
Timing:#!/usr/bin/perl -w use strict; use Scalar::Util qw(weaken); my @data = (1, 2, 3); print time, " test 0: main start\n"; &gogogo(); print time, " test 3: main end\n"; sub gogogo { print time, " test 1: func start\n"; my @h; for (1 .. 200000) { my %hash = (data => \@data); weaken($hash{data}); push @h, \%hash; } print time, " test 2: func end\n"; }
1273747847 test 0: main start 1273747847 test 1: func start 1273747847 test 2: func end 1273747873 test 3: main end
I ran it on i686 Linux, perl v.5.8.8, but the same behaviour is within perl 5.12 :-(
It this a bug or what?
Update. Submitted a bug:
http://rt.perl.org/rt3/Public/Bug/Display.html?id=75254
Thanks for your replies!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Slow GC after Scalar::Util::weaken
by ikegami (Patriarch) on May 21, 2010 at 18:02 UTC | |
|
Re: Slow GC after Scalar::Util::weaken
by MidLifeXis (Monsignor) on May 21, 2010 at 20:27 UTC | |
by MidLifeXis (Monsignor) on Jun 03, 2010 at 16:06 UTC | |
|
Re: Slow GC after Scalar::Util::weaken
by proceng (Scribe) on May 22, 2010 at 04:16 UTC | |
|
Re: Slow GC after Scalar::Util::weaken (O)
by tye (Sage) on Jun 03, 2010 at 16:27 UTC | |
by ikegami (Patriarch) on Jun 03, 2010 at 18:30 UTC | |
|
Re: Slow GC after Scalar::Util::weaken
by ikegami (Patriarch) on Jun 03, 2010 at 17:59 UTC | |
|
Re: Slow GC after Scalar::Util::weaken
by ikegami (Patriarch) on Jun 03, 2010 at 18:13 UTC | |
by jura05 (Novice) on Jun 03, 2010 at 19:31 UTC |