Morning all,
Forgive the naivete, but I'm having trouble wrapping my mind around the
memory implications of using tied hashes, and I haven't found anything in
the Camel book or the Guide to clarify the situation for me.
A fair amount of my Registry scripts need to use code not unlike the
following:
use strict;
use Fcntl;
use MLDBM qw(DB_File Storable);
[...]
tie(my %hash, 'MLDBM', $filename, O_RDONLY, 0644)
or die "Denied $filename: $!\n";
foreach my $item (keys %hash) {
action(\%hash,$item);
}
untie %hash;
I'm intrigued about the memory implications of this kind of construction
where the MLDBM hash is potentially very large. In particular, I'm
looking for reassurance that passing a reference to a hash doesn't copy
the hash itself into memory in any way, and that the memory overhead is
only as large as the largest $item.
Similarly, if I was to
use vars(%hash);
and initialise the tied hash as a global, does this have a significant
memory overhead? Does untie-ing the hash clear the hash contents from
memory, or do I also need to undef the hash to avoid the hash contents
persisting from one request to the next? Is one approach better than the
other?
As I said, my apologies for the newbieness of all this, and even bigger
apologies if it represents an FAQ that I've missed spotting.
Many thanks,
Andrew.
--
perl -MLWP::Simple -e 'getprint("http://www.article7.co.uk/res/japh.txt");'