Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Depth First Search through Digraph Results in Memory Leak

by ysth (Canon)
on Jan 08, 2004 at 11:44 UTC ( [id://319782]=note: print w/replies, xml ) Need Help??


in reply to Depth First Search through Digraph Results in Memory Leak

I think your guess may be right. I changed it to have:
my ($do_search1, $do_search2); $do_search2 = sub { my ($node) = @_; $sub->($node); $explored->{$node->{_id}}++; foreach my $link (@{$node->{_outlinks}}) { die "too deep" unless ($explored->{$link->{_id}}); } }; $do_search1 = sub { my ($node) = @_; $sub->($node); $explored->{$node->{_id}}++; foreach my $link (@{$node->{_outlinks}}) { $do_search2->($link->{_to}) unless ($explored->{$link->{_id}}) +; } }; $do_search = sub { my ($node) = @_; $sub->($node); $explored->{$node->{_id}}++; foreach my $link (@{$node->{_outlinks}}) { $do_search1->($link->{_to}) unless ($explored->{$link->{_id}}) +; } };
so no recursive calls were done, and got:
BUILDING GRAPH Neighbors Node=HASH(0xa0920e8) ID 1 Node=HASH(0xa092160) ID 3 Node=HASH(0xa092124) ID 2 DESTROYING Network=HASH(0xa0420ac) DESTROYING Link=HASH(0xa0921b4) 2 DESTROYING Link=HASH(0xa092184) 1 DESTROYING Link=HASH(0xa0921e4) 3 DESTROYING Link=HASH(0xa092214) 4 DESTROYING Node=HASH(0xa092160) 3 DESTROYING Node=HASH(0xa0920e8) 1 DESTROYING Node=HASH(0xa092124) 2 SHOULD BE THE LAST THING PRINTED, HOWEVER ...
Can you simplify it so you just manually bless a few references into "main" and perlbug it?

Replies are listed 'Best First'.
Re: Re: Depth First Search through Digraph Results in Memory Leak
by djantzen (Priest) on Jan 08, 2004 at 20:43 UTC

    So there's something funky going on with perl's ability to clear lexical pads containing self-referential structures in recursive methods. I think we'll need an internals guru to get any further, but thanks for your feedback ysth.


    "The dead do not recognize context" -- Kai, Lexx

Log In?
Username:
Password:

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

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

    No recent polls found