In addition to the above you can't always rely on Perl to do the right thing with regards to memory return. In our experience perl never really gives back memory to the OS until absolutely forced to. This is referred to as lazy garbage collection by p5p and semi-non-existent garbage collection by some more cynical punters. Also undeffing large hashes can take a very long time on some systems due to a known malloc bug. You may find value in effectively making the reused hashes global in some circumstances:
my %hash; ... sub process { %hash = (); # empty hash but not using undef # do stuff with hash }
As always YMMV.
cheers
tachyon
In reply to Re: undefining hashes to free memory
by tachyon
in thread undefining hashes to free memory
by tigervamp
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |