<?xml version="1.0" encoding="windows-1252"?>
<node id="319782" title="Re: Depth First Search through Digraph Results in Memory Leak" created="2004-01-08 06:44:51" updated="2004-08-22 16:44:22">
<type id="11">
note</type>
<author id="299049">
ysth</author>
<data>
<field name="doctext">
I think your guess may be right.  I changed it to have:
&lt;code&gt;
    my ($do_search1, $do_search2);
    $do_search2 =  sub {

      my ($node) = @_;
      $sub-&gt;($node);
      $explored-&gt;{$node-&gt;{_id}}++;
      foreach my $link (@{$node-&gt;{_outlinks}}) {
          die "too deep" unless ($explored-&gt;{$link-&gt;{_id}});
      }
    };
    $do_search1 =  sub {

      my ($node) = @_;
      $sub-&gt;($node);
      $explored-&gt;{$node-&gt;{_id}}++;
      foreach my $link (@{$node-&gt;{_outlinks}}) {
        $do_search2-&gt;($link-&gt;{_to}) unless ($explored-&gt;{$link-&gt;{_id}});
      }
    };
    $do_search =  sub {

      my ($node) = @_;
      $sub-&gt;($node);
      $explored-&gt;{$node-&gt;{_id}}++;
      foreach my $link (@{$node-&gt;{_outlinks}}) {
        $do_search1-&gt;($link-&gt;{_to}) unless ($explored-&gt;{$link-&gt;{_id}});
      }
    };
&lt;/code&gt;

so no recursive calls were done, and got:
&lt;code&gt;
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 ...
&lt;/code&gt;

Can you simplify it so you just manually bless a few references into "main" and [perlbug] it?</field>
<field name="root_node">
319780</field>
<field name="parent_node">
319780</field>
</data>
</node>
