in reply to Re^2: perl memory re-usage
in thread perl memory re-usage

Sorry, I think you've got it wrong. Lexical (my) variables do not free their memory when they go out of scope. That's what the first FAQ is saying, and it agrees with what many others have said here and elsewhere. For example, see this node by Dan Sugalski.

Replies are listed 'Best First'.
Re^4: perl memory re-usage
by ikegami (Patriarch) on Aug 08, 2006 at 21:41 UTC
    I see what you mean
    use Devel::Peek qw( Dump ); { my $v1 = "test"; Dump($v1); } { my $v2 = "test"; Dump($v2); } { my $v3 = "test"; Dump($v3); } __END__ SV = PV(0x1abea7c) at 0x1ab2710 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01f4 "test"\0 0x1aa01f4 CUR = 4 LEN = 5 SV = PV(0x1abea94) at 0x1ab26f8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01e4 "test"\0 0x1aa01e4 CUR = 4 LEN = 5 SV = PV(0x1abeaac) at 0x1ab2734 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01d4 "test"\0 0x1aa01d4 CUR = 4 LEN = 5
    vs
    use Devel::Peek qw( Dump ); { my $v1 = "test"; Dump($v1); undef $v1; } { my $v2 = "test"; Dump($v2); undef $v2; } { my $v3 = "test"; Dump($v3); undef $v3; } __END__ SV = PV(0x1abea7c) at 0x1ab26d4 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01f4 "test"\0 0x1aa01f4 CUR = 4 LEN = 5 SV = PV(0x1abea94) at 0x1ab26f8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01f4 "test"\0 0x1aa01f4 CUR = 4 LEN = 5 SV = PV(0x1abeaac) at 0x1ab26c8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1aa01f4 "test"\0 0x1aa01f4 CUR = 4 LEN = 5