Stack frames in the CV->PADLIST? $f isn't in something I'd immediately recognize as living in PADLIST but perhaps it is in a temporary. PadWalker would show it, I'll bet.

UPDATED. It'd be possible to remove those RV to the self-CV and decrement their reference count.

use B 'svref_2object'; package B::SV; use overload '""' => sub { my ( $self ) = @_; return sprintf '%s=(%x)', ref $self, $$self; }; package main; sub padinfo { my $cv = svref_2object( $_[0] ); my $cvdepth = $cv->DEPTH; my ( $namesav, @stackav ) = $cv->PADLIST->ARRAY; my @names = map { $_->can('PV') ? $_->PV : undef } $namesav->ARRAY +; my @stack_ref = map [ $_->ARRAY ], @stackav; print STDERR "$_[0]\n"; for my $depth ( 0 .. $#stack_ref ) { if ( $depth == $DEPTH ) { print STDERR '-' x 32; print STDERR "LEVELS FOLLOWING MAY BE REAPED\n"; } print STDERR " $depth\n"; for my $ix ( 0 .. $#{ $stack_ref[$depth] } ) { next unless defined $names[$ix]; print STDERR " $names[$ix]: $stack_ref[$depth][$ix]\n"; print STDERR ' REFCNT:'. $stack_ref[$depth][$ix]->R +EFCNT."\n"; if ( $stack_ref[$depth][$ix]->can( 'RV' ) ) { print STDERR ' '.$stack_ref[$depth][$ix]->R +V."\n"; print STDERR ' REFCNT:'.$stack_ref[$depth][ +$ix]->RV->REFCNT."\n"; } } } } sub refcnt { print STDERR svref_2object( $_[0] )->REFCNT . "\n"; } my $f; $f = sub { my $g = time; $f->( $_[0] - 1 ) if $_[0] >= 0 }; refcnt $f; refcnt \ $f; padinfo $f; $f->(1); refcnt $f; refcnt \i $f; padinfo $f;

PRODUCES

1 # $f 3 # \$f CODE(0x812a180) --------------------------------LEVELS FOLLOWING MAY BE REAPED 0 $g: B::NULL=(81b6818) REFCNT:1 $f: B::RV=(812aac8) REFCNT:2 B::CV=(812a180) REFCNT:1 1 # $f 5 # \$f CODE(0x812a180) --------------------------------LEVELS FOLLOWING MAY BE REAPED 0 $g: B::IV=(81b6818) REFCNT:1 $f: B::RV=(812aac8) REFCNT:4 B::CV=(812a180) REFCNT:1 1 $g: B::IV=(81abe14) REFCNT:1 $f: B::RV=(812aac8) REFCNT:4 B::CV=(812a180) REFCNT:1 2 $g: B::IV=(81abb98) REFCNT:1 $f: B::RV=(812aac8) REFCNT:4 B::CV=(812a180) REFCNT:1

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊


In reply to Re^7: private recursive subroutines by diotalevi
in thread private recursive subroutines by Sixtease

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.