Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

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


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

A workaround is to add a layer in between.
#!/usr/bin/perl -w use strict; use Scalar::Util qw(weaken); my @data = (1, 2, 3); weaken( my $indirection = \@data ); 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 => $indirection); push @h, \%hash; } print time, " test 2: func end\n"; }
You'd have to change
my $data = $h[0]{data};
to
my $data = ${ $h[0]{data} };
if you use this workaround.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-29 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found