in reply to (tye)Re: Tracking Memory Leaks
in thread Tracking Memory Leaks
Just to be clear, the memory used directly by the lexical is not freed but if, for example, the lexical contains the last reference to something, then that something will be destroyed and its memory freed when the lexical's scope is left (or when the last reference to the lexical is destroyed). So this is mostly a problem when dealing with long strings rather than objects.
No, I don't think that's correct. The memory will not be freed, if by freed you mean "available for use by other variables in my program". It will be re-used if you use that lexical again. See this post from Doug MacEachern for more info on this.
I'm not sure the closures thing I was talking about is really a bug; it's just a side-effect of nested subs and closures. If you do this, it will leak like crazy:
my $foo; sub bar { sub baz { $foo++; } }
It's creating a new private copy of $foo for baz() every time. Using Error.pm can sometimes lead people to do this without realizing it, when they use nested try/catch blocks.
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re2: Tracking Memory Leaks
by tye (Sage) on Aug 15, 2001 at 23:02 UTC | |
by perrin (Chancellor) on Aug 15, 2001 at 23:35 UTC |
In Section
Seekers of Perl Wisdom