in reply to Re: Re: Re: Memory usage breakup
in thread Memory usage breakup

Huh. I just tried your code and got the same results. I find that surprising; I would expect constant folding to happen at compile time, and so for the memory to be allocated at the start step.

Replies are listed 'Best First'.
Re^5: Memory usage breakup
by hv (Prior) on May 01, 2004 at 18:08 UTC

    You're right, I would have expected that too. Looking more closely, it turns out that it doesn't get constant-folded at all - I guess the repeat operator isn't included for that optimisation.

    (I checked by modifying the code to call the coderef twice, and then examined the trace produced by perl -Dt.)

    So it would appear that it is just the anonymous pad variable for the subexpression target that is grabbing the memory.

    Hugo