Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2022-12-01 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?