Somehow, in the last few days I stumble more over perl peculiarities, than in last few years :)
Again. I wanted to check how perl handles memory when I use substr($a, 0, 1) = ''. So I've used Devel::Peek to try the following code
To my surprise it has produced the outputuse Devel::Peek 'Dump'; use strict; my $a = "test"; substr($a, 0, 2) = ''; Dump $a;
SV = PV(0x22d3088) at 0x22f1968 REFCNT = 2 FLAGS = (PADMY,POK,OOK,pPOK) OFFSET = 2 PV = 0x22e26b2 ( "t\2" . ) "st"\0 CUR = 2 LEN = 6REFCNT is 2! Why? At first I thought, that this has something to do with the Devel::Peek, but after checking few other situations, I'm sure, that this happens only when I use substr to modify the content of the variable. Is there some internal reason for incrementing the reference count for the variable, or it is just a bug?
In reply to is this a memory leak or do I miss something? by andal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |