memory leaks in perl

Rick Delaney rick-h4KjNK7Mzas at public.gmane.org
Sat May 1 14:59:28 UTC 2004


On Sat, May 01, 2004 at 08:39:16AM -0400, Stewart C. Russell wrote:
> 
> >    undef $hash{$key}
> 
> That wouldn't work. That's the same as saying $hash{key} = undef -- it's 

That's not true.  undef($scalar) frees the memory used by $scalar.
$scalar = undef will leave $scalar using lots of memory if it was
previously using lots of memory.

> setting the value to undef, not freeing up the key.

Obviously it doesn't free the key, but it does free the value.  But I'm
pretty sure delete($hash{$key}) will free the value too.

-- 
Rick Delaney
rick-h4KjNK7Mzas at public.gmane.org
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list