I think it's related to the optimization described in No garbage collection for my-variables (not sure though).
The linked post refers to the effect of the padsv (my $) operator. Neither padsv nor the underlying code (SAVECLEARSV) is involved here. Any resemblance is coincidental.
In fact, I don't think there's any reuse of allocated memory involved. I think a new memory block just happens to be allocated at the same location as a previously allocated memory block. (Upd: That's indeed what happens, as show in Re^5: Reference of constants and literals )
For example, the following code continually allocates memory blocks at the same two locations. This is not related to my since we're forcing my to continually reallocate SVs by keeping the refcount greater than 1. There is no reuse of allocated memory at all.
>perl -le"sub f{ \my $x } print f() for 1..10;" SCALAR(0x236d40) SCALAR(0x236014) SCALAR(0x236d40) SCALAR(0x236014) SCALAR(0x236d40) SCALAR(0x236014) SCALAR(0x236d40) SCALAR(0x236014) SCALAR(0x236d40) SCALAR(0x236014)
In reply to Re^4: Reference of constants and literals
by ikegami
in thread Reference of constants and literals
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |