As for the additional memory, when you Devel::Peek::Dump() the reference (with a shorter string), you can see that a PV has been created after having accessed the string (via "magic"). My first guess would be this is some caching behavior to increase performance with repeated accesses.
use Devel::Peek; $v = chr(0); $v x= 50; $r = \substr $v, 25; Dump $r; vec( $v, 25, 8 ) = 0b10101010; print vec( $$r, $_, 1 ) for 0..7; Dump $r; __END__ SV = IV(0x7991e0) at 0x7991f0 REFCNT = 1 FLAGS = (ROK) RV = 0x771998 SV = PVLV(0x7a1ce0) at 0x771998 REFCNT = 1 FLAGS = (GMG,SMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x7914f0 MG_VIRTUAL = &PL_vtbl_substr MG_TYPE = PERL_MAGIC_substr(x) TYPE = x TARGOFF = 25 TARGLEN = 25 TARG = 0x7991c0 SV = PV(0x76fc20) at 0x7991c0 REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x7a4f50 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ +0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\0 CUR = 50 LEN = 56 0 1 0 1 0 1 0 1 SV = IV(0x7991e0) at 0x7991f0 REFCNT = 1 FLAGS = (ROK) RV = 0x771998 SV = PVLV(0x7a1ce0) at 0x771998 REFCNT = 1 FLAGS = (GMG,SMG,pPOK) IV = 0 NV = 0 PV = 0x7917e0 "\252\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ +0"\0 # <--- CUR = 25 LEN = 32 MAGIC = 0x7914f0 MG_VIRTUAL = &PL_vtbl_substr MG_TYPE = PERL_MAGIC_substr(x) TYPE = x TARGOFF = 25 TARGLEN = 25 TARG = 0x7991c0 SV = PV(0x76fc20) at 0x7991c0 REFCNT = 2 FLAGS = (POK,pPOK) PV = 0x7a4f50 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\ +0\252\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"\0 CUR = 50 LEN = 56
In reply to Re: More 64-bit Perl bugs?
by Eliya
in thread More 64-bit Perl bugs?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |