Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Slow GC after Scalar::Util::weaken

by ikegami (Patriarch)
on Jun 03, 2010 at 18:13 UTC ( [id://842968]=note: print w/replies, xml ) Need Help??


in reply to Slow GC after Scalar::Util::weaken

Alternate workaround: Destroy the strong ref before the weak refs:
#!/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"; undef $data; return; }

The undef can't be the last statement for reasons unclear to me.

Replies are listed 'Best First'.
Re^2: Slow GC after Scalar::Util::weaken
by jura05 (Novice) on Jun 03, 2010 at 19:31 UTC
    Thanks, ikegami! I would agree with tye that is not normal use-case; I should rework my code.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://842968]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-19 11:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found