in reply to Re: Re: Improving memory performance
in thread Improving memory performance

There's only one pad per subroutine, so it's per-sub.
  • Comment on Re: Re: Re: Improving memory performance

Replies are listed 'Best First'.
Re: Re: Re: Re: Improving memory performance
by shotgunefx (Parson) on Oct 04, 2002 at 17:35 UTC
    Excuse my ignorance, I maybe just reading your answer the wrong way but from perlguts
    So each subroutine is born with an array of scratchpads (of length 1). On each entry to the subroutine it is checked that the current depth of the recursion is not more than the length of this array, and if it is, new scratchpad is created and pushed into the array.


    -Lee

    "To be civilized is to deny one's nature."
      Right, perl keeps a stack of pads per sub, but each sub only has a single pad in play at once. What I was talking about is something like:
      sub foo { my $bar; { my $bar; { my $bar; } } }
      While there are three blocks, and three $bars in there, there's still only one pad. Leaving the inner blocks doesn't exit any pads, nor does it clean any pads up. (The compiler plays some magic games to determine which $bar in the sub pad is in effect at any particular line of the sub)